Link Prediction with Relational Hypergraphs

## Abstract

Abstract Link prediction with knowledge graphs has been thoroughly studied in graph machine learning, leading to a rich landscape of graph neural network architectures with successful applications. Nonetheless, it remains challenging to transfer the success of these architectures to relational hypergraphs , where the task of link prediction is over k 𝑘 k italic_k -ary relations , which is substantially harder than link prediction with knowledge graphs.
In this paper, we propose a framework for link prediction with relational hypergraphs, unlocking applications of graph neural networks to fully relational structures. Theoretically, we conduct a thorough analysis of the expressive power of the resulting model architectures via corresponding relational Weisfeiler-Leman algorithms and also via logical expressiveness. Empirically, we validate the power of the proposed model architectures on various relational hypergraph benchmarks. The resulting model architectures substantially outperform every baseline for inductive link prediction, and lead to state-of-the-art results for transductive link prediction.

## 1 Introduction

Figure: Figure 1: A relational hypergraph over the relations $\mathsf{StudyDegree}$ and $\mathsf{Awarded}$. The facts $\mathsf{StudyDegree}(\mathsf{Hawking},\mathsf{Oxford},\mathsf{Physics},\mathsf {BA})$ and $\mathsf{Awarded}(\mathsf{Physics},\mathsf{Nobel},\mathsf{Oxford})$ are *ordered* hyperedges, where the order of entities in each fact is denoted by dashed arrows.

Knowledge graphs consist of facts (or, edges) representing different relations between *pairs of nodes*. Knowledge graphs are inherently incomplete [, ] which motivated a large literature on link prediction with knowledge graphs [, , , , , , ]. This task amounts to predicting missing facts in the knowledge graph and has led to a rich landscape of graph neural network architectures [, , , ]. Our understanding of these architectures is supported by theoretical studies quantifying their expressive power [, , ].

In this work, we are interested in link prediction on *fully relational* data, where every relation is between $k$ nodes, for any *relation-specific* choice of $k$. Relational data can encode rich relationships between entities; e.g., consider a relationship between *four* entities: “$\mathsf{Hawking}$ went to $\mathsf{Oxford}$ to study $\mathsf{Physics}$ and received a $\mathsf{BA}$ degree”. This can be represented with a fact $\mathsf{StudyDegree}(\mathsf{Hawking},\mathsf{Oxford},\mathsf{Physics},\mathsf
{BA})$.
Clearly, relational data can be represented via relational hypergraphs, where each *ordered, relational hyperedge* in the hypergraph corresponds to a relational fact (see Figure 1). The focus of this work is hence relational hypergraphs — not to be confused with other graph types, e.g., hyper-relational knowledge graphs [, ], discussed in Section 2.

Motivation.
Given the prevalence of relational data, link prediction with relational hypergraphs has been widely studied in the context of shallow embedding models [, , , ], where the idea is to generalize knowledge graph embedding methods to relational hypergraphs. The key limitation of these approaches is that they are all *transductive*: they cannot be directly used to make predictions between nodes that are not seen during training. The exact same limitation has motivated the development of graph neural network architectures for *inductive* link prediction on knowledge graphs — enabling for predictions between nodes that are not seen during training [] — which eventually led to very strong architectures such as NBFNets [].

Figure: Figure 2: Unary encoders cannot distinguish the query facts $r(u,v,t)$ and $r(u,w,t)$, drawn in green.

In the same spirit, graph neural networks have been extended for inductive link prediction on relational hypergraphs [, ], but these approaches do not enjoy the same level of success.
This can be attributed to multiple, related factors. In essence, link prediction with relational hypergraphs is a $k$-ary task (for $k$ varying depending on the relation), which is much more challenging than a binary prediction task and requires dedicated approaches. On the other hand, existing proposals are simple extensions of relational graph neural networks (such as RGCNs []), which cannot adequately capture $k$-ary tasks. In fact, these architecture are *unary* encoders that are used for $k$-ary predictions, which is known to be a fundamental limitation [, ]. To make these points concrete, let us consider the example shown in Figure 2. In this example, regardless of the choice of the *unary* encoder, it is not possible to distinguish between the query facts $r(u,w,t)$ and $r(u,v,t)$, because the nodes $w$ and $v$ are isomorphic in the hypergraph. However, an appropriate *ternary* encoder can easily differentiate these facts using the information that the distance between the nodes $u$ and $w$ differs from the distance between the nodes $u$ and $v$. These limitations along with a lack of an established theory motivates our study.

Approach. We first investigate the expressive power of existing graph neural networks proposed for relational hypergraphs — such as G-MPNNs [] and RD-MPNNs [] — to rigorously identify their limitations. This is achieved by studying the framework of *hypergraph relational message passing neural networks* (HR-MPNNs) which subsumes these architectures.
To address the limitations of HR-MPNNs, we introduce *hypergraph conditional message passing neural networks* (HC-MPNNs) as a framework for inductive link prediction inspired by the conditional message passing paradigm studied for knowledge graphs [, ]. We conduct a systematic expressiveness study showing that HC-MPNNs can compute richer properties of nodes — dependent on $k$ other nodes — when compared to HR-MPNNs. Specifically, our study for expressive power answers the following questions:

- 1.
*Which nodes can be distinguished by an architecture?* To answer this question, we generalize existing results given for graph neural networks on knowledge graphs [, ] using Weisfeler-Leman algorithms designated for relational hypergraphs.
- 2.
*What properties of nodes can be uniformly expressed by an architecture?* To answer this question, we investigate logical expressiveness which situates the class of node properties that can be expressed by an architecture within an appropriate logical fragment.

Contributions. Our main contributions can be summarized as follows:

- •
We rigorously identify the expressive power and limitations of HR-MPNNs that encompass most of the existing architectures for link prediction with relational hypergraphs (Section 4).
- •
We introduce the novel framework of HC-MPNNs, which includes more expressive architectures, such as HCNets, and addresses the core limitations of HR-MPNNs (Section 5).
- •
We present a detailed empirical analysis to validate our theoretical findings (Section 6 and Appendix K).
Experiments for inductive link prediction with relational hypergraphs show that a simple HC-MPNNs architecture surpasses all existing baselines by a great margin. Our ablation studies on different model components justify the importance of our model design choices. We supplement the real-world experiments with a synthetic experiment inspired by the example from Figure 2 to validate the expressive power of HC-MPNNs in Appendix N.

All proofs and additional experiments (including state-of-the-art transductive link prediction results) can be found in the appendix of this paper.

## 2 Related work

Knowledge graphs.
Link prediction with knowledge graphs has been studied extensively in the literature. Early literature is dominated by knowledge graph embedding models including TransE [], RotatE [], ComplEx [],
TuckER [], and BoxE [], which are all restricted to the *transductive* regime.
In the space of graph neural networks, RGCN [] and CompGCN [] emerged as architectures extending standard message passing neural networks [] to knowledge graphs using a relational message passing scheme.
GraIL [] is the first architecture explicitly designed to operate in the *inductive* regime,
but it suffers from a high computational complexity.
Zhu et al. [] proposed NBFNets as an architecture that subsumes previous methods such as NeuralLP [] and DRUM []. NBFNets perform strongly and have better computational complexity thanks to their high parallelizability []. Recently, A*Net [] is proposed to scale NBFNets further with the usage of a neural priority function. NBFNets are shown to fall under the framework of *conditional message passing neural networks* (C-MPNNs) [], as they compute node representations “conditioned” pairwise on other node representations, making these architectures suitable for binary link prediction tasks and explaining their superior performance. The success of conditional message passing on knowledge graphs serves as a motivation for our work on relational hypergraphs.

Relational hypergraphs.
Link prediction with relational hypergraphs has been widely studied in the context of shallow embedding models [, , , ]. To score facts of the form $r(u_{1},\cdots,u_{k})$, some methods extend the scoring function (i.e., decoder) of existing knowledge graph embedding methods to consider multiple entities. For example, m-TransH [] is an extension of TransH [] designed to handle multiple entities jointly. Similarly, GETD [] builds on the bilinear embedding method TuckER [] to handle higher-arity relations. Fatemi et al. [] proposed HSimplE and HypE that disentangle the position and relation embedding. BoxE [] is an embedding model that encodes each relation using box embeddings, and naturally applies to $k$-ary relations (using $k$ boxes) while achieving strong results on transductive benchmarks. Fatemi et al. [] explores the connection between relational algebra and relational hypergraph embeddings and proposes ReAlE.
In the space of graph neural networks, Feng et al. [] and Yadati et al. [] leverage message-passing methods on *undirected* hypergraphs. The first approach that is tailored to relational hypergraphs is G-MPNN [], which operates by relational message passing. RD-MPNNs [] builds on this approach and additionally incorporates the positional information of entities in their respective relations during message passing, which is critical for relational facts since the order of nodes in each edge clearly matters. G-MPNN and RD-MPNNs represent closest related works to the present study and we show that these architectures are instances of HR-MPNNs and hence are subject to the same limitations.

Hyper-relational knowledge graphs and beyond. Our study is completely orthogonal to hyper-relational knowledge graphs [, ], which are knowledge graphs where each edge is additionally augmented with additional information: a multiset of “qualifier-value” pairs. There are other related works proposing alternative representations for $n$-ary relations []
relying on *unordered* hypergraphs, where each relational edge is represented by a multiset of “role-value” pairs. This is drastically different from our approach, as we operate directly on higher-arity relational data in its full generality given in the form of relational hypergraphs (see Appendix B for more details).

## 3 Link prediction with relational hypergraphs

Relational hypergraphs. A *relational hypergraph* $G=(V,E,R,c)$ consists of a set $V$ of *nodes*, a set $E$ of *hyperedges* (or simply edges or facts) of the form $e=r(u_{1},\ldots,u_{k})\in E$ where $r\in R$ is a *relation type*, $u_{1},\ldots,u_{k}\in V$ are nodes, and $k=\mathtt{ar}(r)$ is the arity of the relation $r$. We consider labeled hypergraphs, where the labels are given by a coloring function on nodes $c:V\rightarrow D$. If the range of this coloring satisfies $D=\mathbb{R}^{d}$, we say $c$ is a $d$-dimensional *feature map* and use the notation ${\bm{x}}$.
We write $\rho(e)$ as the relation $r\in R$ of the hyperedge $e\in E$, and $e(i)$ to refer to the node in the $i$-th arity position of the hyperedge $e$.
We define $E{(v)}=\left\{(e,i)\mid e(i)=v,e\in E,1\leq i\leq\mathtt{ar}(\rho(e))\right\}$ as the set of edge-position pairs of a node $v$.
Intuitively, this set captures all occurrences of node $v$ in different hyperedges and arity positions. We also define the *positional neighborhood* of a hyperedge $e$ with respect to a position $i$ as ${\mathcal{N}}_{i}(e)=\left\{(e(j),j)\mid j\neq i,1\leq j\leq\mathtt{ar}(\rho(e
))\right\}$.
This set represents all nodes that co-occur with the node at position $i$ in a hyperedge $e$, along with their positions. A *knowledge graph* is a relational hypergraph where for all $r\in R$, $\mathtt{ar}(r)=2$.

Link prediction on hyperedges.
Given a relational hypergraph $G=(V,E,R,c)$, and a *query* $q(u_{1},...,u_{t-1},?,u_{t+1}...,u_{k})$, where $q\in R$ is the query relation and “$?$” is the querying position, *link prediction* is the problem of scoring all the hyperedges obtained by substituting nodes $v\in V$ in place of “$?$”.
We denote a $k$-tuple $(u_{1},\ldots,u_{k})$ by ${\bm{u}}$ and
the tuple $(u_{1},\ldots,u_{t-1},u_{t+1},\ldots,u_{k})$ by $\tilde{{\bm{u}}}$. For convenience, we commonly write a query as a tuple ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$.

Isomorphisms. An *isomorphism* from a relational hypergraph ${G=(V,E,R,c)}$ to a relational hypergraph ${G^{\prime}=(V^{\prime},E^{\prime},R,c^{\prime})}$ is a bijection $f:V\to V^{\prime}$ such that $c(v)=c^{\prime}(f(v))$ for all $v\in V$, and $r(u_{1},\cdots,u_{k})\in E$ if and only if $r(f(u_{1}),\cdots,f(u_{k}))\in E^{\prime}$, for all $r\in R$ and $u_{1},\cdots,u_{k}\in V$.

Invariants. For $k\geq 1$, we define a *$k$-ary relational hypergraph invariant* as a function $\xi$ associating with each relational hypergraph $G=(V,E,R,c)$ a function $\xi(G)$ with domain $V^{k}$ such that for all relational hypergraphs $G,G^{\prime}$, all isomorphisms $f$ from $G$ to $G^{\prime}$, and for all $k$-tuples of nodes ${\bm{u}}\in V^{k}$, we have $\xi(G)({\bm{u}})=\xi(G^{\prime})(f({\bm{u}}))$.

Refinements. Given two relational hypergraph invariants $\xi$ and $\xi^{\prime}$, we say a function $\xi(G):V^{k}\to D$ *refines* a function $\xi^{\prime}(G):V^{k}\to D$, denoted as $\xi(G)\preceq\xi^{\prime}(G)$, if for all ${\bm{u}},{\bm{u}}^{\prime}\in V^{k}$, $\xi(G)({\bm{u}})=\xi(G)({\bm{u}}^{\prime})$ implies $\xi^{\prime}(G)({\bm{u}})=\xi^{\prime}(G)({\bm{u}}^{\prime})$. In addition, we call such functions *equivalent*, denoted as $\xi(G)\equiv\xi^{\prime}(G)$, if $\xi(G)\preceq\xi^{\prime}(G)$ and $\xi^{\prime}(G)\preceq\xi(G)$. A $k$-ary relational hypergraph invariant $\xi$ *refines* a $k$-ary relational hypergraph invariant $\xi^{\prime}$, if $\xi(G)$ refines $\xi^{\prime}(G)$ for all relational hypergraphs $G$. Similarly for equivalence.

## 4 Hypergraph relational MPNNs

We first introduce HR-MPNNs, which capture existing architectures tailored for relational hypergraphs, such as G-MPNN [] and RD-MPNN [] (see Section C.1 for details).

Let $G=(V,E,R,{\bm{x}})$ be a relational hypergraph, where ${\bm{x}}$ is a feature map that yields the initial node features ${\bm{x}}_{v}={\bm{x}}(v)$ for all nodes $v\in V$. For $\ell\geq 0$, an HR-MPNN iteratively computes a sequence of feature maps ${\bm{h}}^{(\ell)}:V\mapsto\mathbb{R}^{d(\ell)}$, where the representations ${\bm{h}}_{v}^{(\ell)}:={\bm{h}}^{(\ell)}(v)$ are given by:

$$ $\displaystyle{\bm{h}}_{v}^{(0)}$ $\displaystyle={\bm{x}}_{v},$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{v}^{(\ell)},\textsc{Agg}\big{(}{\bm{ h}}_{v}^{(\ell)},\{\!\!\{\textsc{Msg}_{\rho(e)}\big{(}\{({\bm{h}}_{w}^{(\ell)} ,j)\mid(w,j)\in{\mathcal{N}}_{i}(e)\}\big{)}\mid(e,i)\in E(v)\}\!\!\}\big{)} \Big{)},$ $$

where Up, Agg, and $\textsc{Msg}_{\rho(e)}$ are differentiable, *update*, *aggregation*, and relation-specific *message* functions, respectively. These functions are layer-specific, but we omit the superscript $(\ell)$ for brevity. An HR-MPNN has a fixed number of layers $L\geq 0$ and the final representations of nodes are given by the function ${\bm{h}}^{(L)}:V\rightarrow\mathbb{R}^{d(L)}$.
We can then use a $k$-ary decoder $\textsc{dec}_{q}:\mathbb{R}^{d(L)\times k}\rightarrow\mathbb{R}$, to produce a score for the likelihood of $q({\bm{u}})$ for $q\in R,{\bm{u}}\in V^{k}$.

HR-MPNNs trivially contain architectures designed for single-relational, undirected hypergraphs, such as HGNN [] and HyperGCN [] (see Section C.2 for details). Furthermore, HR-MPNNs capture relational message passing neural networks on knowledge graphs [], as a special case (see Section C.3 for a proof).

Expressive power of MPNNs is well-understood both in terms of their ability to distinguish graph nodes [, ] and in terms of their capacity to capture logical node properties []. This line of work has been extended to relational architectures [, ]. In the next subsections, we provide similar characterizations for HR-MPNNs.

### 4.1 A Weisfeiler-Leman test for HR-MPNNs

We formally characterize the ability of HR-MPNNs to distinguish nodes in relational hypergraphs via a variant of the 1-dimensional Weisfeiler-Leman test, namely the *hypergraph relational 1-WL test*, denoted by ${\sf hrwl}_{1}$. The test ${\sf hrwl}_{1}$ is a natural generalization of ${\sf rwl}_{1}$ [] to relational hypergraphs.
Given a relational hypergraph $G=(V,E,R,c)$, for $\ell\geq 0$, ${\sf hrwl}_{1}$ updates the node colorings as:

$$ $\displaystyle{\sf hrwl}_{1}^{(0)}(v)$ $\displaystyle=c(v),$ $\displaystyle{\sf hrwl}_{1}^{(\ell+1)}(v)$ $\displaystyle=\tau\Big{(}{\sf hrwl}_{1}^{(\ell)}(v),\!\{\!\!\{\big{(}\{({\sf hrwl }_{1}^{(\ell)}(w),j)\!\mid(w,j)\in{\mathcal{N}}_{i}(e)\},\rho(e)\big{)}\!\mid \!(e,i)\!\in\!E(v)\}\!\!\}\Big{)}.$ $$

The function $\tau$ is an injective mapping that maps the above pair to a unique color that has not been used in previous iterations: ${\sf hrwl}_{1}^{(\ell)}$ defines a valid node invariant on relational hypergraphs for all $\ell\geq 0$.

As it turns out, ${\sf hrwl}_{1}$ has the same expressive power as HR-MPNNs in terms of distinguishing nodes over relational hypergraphs:

###### Theorem 4.1 .

Let $G=(V,E,R,c)$ be a relational hypergraph, then the following statements hold:

- 1.
For all initial feature maps ${\bm{x}}$ with $c\equiv{\bm{x}}$, all HR-MPNNs with $L$ layers, and for all $0\leq\ell\leq L$, it holds that ${\sf hrwl}_{1}^{(\ell)}\preceq{\bm{h}}^{(\ell)}$.
- 2.
For all $L\geq 0$, there is an initial feature map ${\bm{x}}$ with $c\equiv{\bm{x}}$ and an HR-MPNN with $L$ layers, such that for all $0\leq\ell\leq L$, we have ${\sf hrwl}_{1}^{(\ell)}\equiv{\bm{h}}^{(\ell)}$.

Intuitively, item (1) states that ${\sf hrwl}_{1}$ upper bounds the power of any
HR-MPNN: if the test cannot distinguish two nodes, then HR-MPNNs cannot either. On the other hand, item
(2) states that HR-MPNNs can be as expressive as ${\sf hrwl}_{1}$: for any $L$, there is an HR-MPNN that simulates $L$ iterations of the test. In our proof, we explicitly construct this HR-MPNN using a simple architecture: the proof requires a very delicate construction to ensure the HR-MPNN synthetizes the information around a node $v$ (given by its neighborhood $E(v)$), in the same way ${\sf hrwl}_{1}$ does (see Appendix D).

###### Theorem 4.1 .

### 4.2 Logical expressiveness of HR-MPNNs

The previous WL characterization of HR-MPNNs is *non-uniform* in the sense that it holds for a given relational hypergraph $G$. We now turn our attention to a *uniform* analysis of the power of HR-MPNNs and study the problem of which *(node) properties* can be expressed as HR-MPNNs.
Following Barceló et al. [], we investigate *logical* classifiers, i.e., those that can be defined in the formalism of first-order logic (FO). Briefly, a first-order formula $\phi(x)$ with one free variable $x$ defines a logical classifier that assigns value ${\sf true}$ to node $u$ in relational hypergraph $G$ whenever $G\models\phi(u)$.
A logical classifier $\phi(x)$ is captured by a HR-MPNN $\cal A$ if for every relational hypergraph $G$ the nodes $u$ that are classified as ${\sf true}$ by $\phi$ and $\cal A$ are the same.

Graded modal logic on hypergraphs. Barceló et al. [] showed that a logical classifier is captured by an MPNN over single-relational undirected graphs if and only if it can be expressed in *graded modal logic* [, ]. This result is extended to knowledge graphs by Huang et al. []. We consider a variant of graded modal logic for hypergraphs. Fix a set of relation types $R$ and a set of node colors $\mathcal{C}$.
The *hypergraph graded modal logic* (HGML) is the fragment of FO containing the following unary formulas. Firstly, $a(x)$ for $a\in\mathcal{C}$ is a formula. Secondly, if $\varphi(x)$ and $\varphi^{\prime}(x)$ are HGML formulas, then $\neg\varphi(x)$ and $\varphi(x)\land\varphi^{\prime}(x)$ also are. Thirdly, for $r\in R$, $1\leq i\leq{\textsf{ar}}(r)$ and $N\geq 1$:

$$ $\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x, y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\Psi(\tilde{{\bm{y}}})\Big{)}$ $$

is a HGML formula, where $\tilde{{\bm{y}}}=(y_{1},\dots,y_{i-1},y_{i+1},\dots,y_{{\textsf{ar}}(r)})$ and $\Psi(\tilde{{\bm{y}}})$ is a Boolean combination of HGML formulas having free variables from $\tilde{{\bm{y}}}$. Intuitively, the formula expresses that $x$ participates in at least $N$ edges $e$ at position $i$, such that the remaining nodes in $e$ satisfy condition $\Psi$.

###### Example 4.2 .

Consider the set of relations from Figure 1 and the property: “$x$ is a person who obtained a degree $y$ of a subject $z$ at a university $m$ that has been awarded less than two prices $p$ of some subject $w$.” This can be expressed as the following formula:

$$ $\phi(x)=\text{Person}(x)\,\land\,\exists y,z,m\Big{(}\,\text{StudyDegree}(x,y, z,m)\,\land\,\neg\exists^{\geq 2}p,w\,(\text{Awarded}(w,p,m))\,\Big{)}$ $$

It is easy to verify that $\phi(x)$ is indeed a HGML formula.
$\diamond$

For any property expressed in HGML, such as $\phi(x)$, does there exist an HR-MPNN that captures this property on *all* relational hypergraphs with a shared relation vocabulary $R$ and node colors ${\cal C}$? Indeed, we show that HR-MPNNs are as powerful as HGML (see Appendix E for details):

###### Theorem 4.3 .

Each hypergraph graded modal logic classifier is captured by a HR-MPNN.

For the proof, we first show a simple normal form for HGML formulas, and then carefully translate formulas of this form into HR-MPNNs. We conjecture that the converse to Theorem 4.3 also holds.

###### Example 4.2 .

###### Theorem 4.3 .

## 5 Hypergraph conditional MPNNs

Figure: Figure 3: Given a relational hypergraph $G$ with $V=\{a,b,c,d,e\}$, $E=\{r_{1}(a,b,d,c),\allowdisplaybreaks r_{2}(d,e,b)\}$, $R=\{r_{1},r_{2}\}$ and a query $q(b,?,a)$, HCNet conditions on the nodes $a$ and $b$ and then applies message passing to compute the score for $q(b,e,a)$. Here, ${\bm{z}}_{q}$ is the learnable relation vector for query relation, and ${\bm{p}}_{i}$ is the positional encoding of the $i$-th arity position.

In this section, we propose *hypergraph conditional message passing networks* (HC-MPNNs), a generalization of C-MPNNs [] to relational hypergraphs.

Let $G=(V,E,R,{\bm{x}})$ be a relational hypergraph, where ${\bm{x}}$ is a feature map. Given a query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$, for $\ell\geq 0$, an HC-MPNN computes a sequence of feature maps ${\bm{h}}_{v|{\bm{q}}}^{(\ell)}$ as follows:

$$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(0)}$ $\displaystyle=\textsc{Init}(v,{\bm{q}}),$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(\ell+1)}$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{v|{\bm{q}}}^{(\ell)},\textsc{Agg} \big{(}{\bm{h}}_{v|{\bm{q}}}^{(\ell)},\{\!\!\{\textsc{Msg}_{\rho(e)}\big{(}\{( {\bm{h}}_{w|{\bm{q}}}^{(\ell)},j)\mid(w,j)\in{\mathcal{N}}_{i}(e)\},{\bm{q}} \big{)},\mid(e,i)\in E(v)\}\!\!\}\big{)}\Big{)},$ $$

where Init, Up, Agg, and $\textsc{Msg}_{\rho(e)}$ are differentiable *initialization*, *update*, *aggregation*, and relation-specific *message* functions, respectively. An HC-MPNN has a fixed number of layers $L\geq 0$, and the final
conditional node representations are given by ${\bm{h}}_{v|{\bm{q}}}^{(L)}$.
We denote by ${\bm{h}}^{(\ell)}_{\bm{q}}:V\rightarrow\mathbb{R}^{d(\ell)}$ the function ${\bm{h}}^{(\ell)}_{\bm{q}}(v):={\bm{h}}_{v|{\bm{q}}}^{(\ell)}$.

To ensure that HC-MPNNs compute $k$-ary representations (see Appendix I), we impose a generalized version of *target node distinguishability* proposed by Huang et al. [].
An initialization function satisfies *generalized target node distinguishability* if
for all ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$:

$$ $\textsc{Init}(u,{\bm{q}})\neq\textsc{Init}(v,{\bm{q}}),\forall u\in\tilde{{\bm {u}}},v\notin\tilde{{\bm{u}}}~{}~{}~{}\text{ and }~{}~{}~{}\textsc{Init}(u_{i} ,{\bm{q}})\neq\textsc{Init}(u_{j},{\bm{q}}),\forall u_{i},u_{j}\in\tilde{{\bm{ u}}},u_{i}\neq u_{j}$ $$

Differently from message passing on *simple* hypergraphs, we need to consider the relation type of each edge (multi-relational) and the relative position of each node (directed) in the edges on relational hypergraphs. Hence, the message function $\textsc{Msg}_{\rho(e)}$ needs to be relation-specific while also keeping track of the positions $j$ of nodes $w$ in their respective neighborhoods ${\mathcal{N}}_{i}(e)$. We can then obtain the scores of query ${\bm{q}}$ applying a unary decoder dec on ${\bm{h}}_{v|{\bm{q}}}^{(L)}$.

### 5.1 Hypergraph conditional networks

We define a *basic* instance of HC-MPNNs, which we call *hypergraph conditional networks* (HCNets). For a query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$, an HCNet computes the following representations for all $\ell\geq 0$:

$$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(0)}$ $\displaystyle=\sum_{i\neq t}\mathbbm{1}_{v=u_{i}}*({\bm{p}}_{i}+{\bm{z}}_{q}),$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(\ell+1)}$ $\displaystyle=\sigma\Big{(}{\bm{W}}^{(\ell)}\Big{[}{\bm{h}}_{v|{\bm{q}}}^{( \ell)}\Big{\|}\sum_{(e,i)\in E(v)}g_{\rho(e),q}^{(\ell)}\Big{(}\odot_{j\neq i} (\alpha^{(\ell)}{\bm{h}}_{e(j)|{\bm{q}}}^{(\ell)}\!\!+(1-\alpha^{(\ell)}){\bm{ p}}_{j})\Big{)}\Big{]}+{\bm{b}}^{(\ell)}\Big{)},$ $$

where $g_{\rho(e),q}^{(\ell)}$ is learnable message function, $\sigma$ is an activation function, ${\bm{W}}^{(\ell)}$ is a learnable weight matrix, ${\bm{b}}^{(\ell)}$ as learnable bias term per layer, ${\bm{z}}_{q}$ is the learnable query vector for $q\in R$, and $\mathbbm{1}_{C}$ is the indicator function that returns $1$ if condition $C$ is true, and 0 0 otherwise. As usual, $*$ is scalar multiplication, and $\odot$ is element-wise multiplication of vectors. We write $\alpha$ to refer to a learnable scalar and ${\bm{p}}_{i}$ to refer to the positional encoding at position $i$, which is sinusoidal positional encoding [].

In particular, we set $g_{\rho(e),q}^{(\ell)}$ to be a *query-dependent* diagonal linear map $\operatorname{Diag}({\bm{W}}_{r}{\bm{z}}_{q})$ where ${\bm{W}}_{r}$ is a learnable matrix for each relation $r$. Alternatively, we can adopt a *query-independent* map by replacing ${\bm{W}}_{r}{\bm{z}}_{q}$ with learnable vector ${\bm{w}}_{r}$ for each relation $r$.

Intuitively, the model initialization ensures that all *source nodes* (i.e., nodes that appear in $\tilde{{\bm{u}}}$) are initialized to their respective positions in the query edge, and all other nodes are initialized as the zero vector $\mathbf{0}$ satisfying generalized target node distinguishability. The visualization of HCNet is shown in Figure 3.

### 5.2 A Weisfeiler-Leman test for HC-MPNNs

To analyze the expressive power of HC-MPNNs for distinguishing nodes, we can still use the ${\sf hrwl}_{1}$ test provided we restrict ourselves to initial colorings $c$ that respect the given query ${\bm{q}}$. Formally, given a query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$ on a relational hypergraph $G=(V,E,R,c)$, we say that the coloring $c$ satisfies *generalized target node distinguishability with respect to ${\bm{q}}$* if:

$$ $\displaystyle c(u)\neq c(v)\quad\forall u\in\tilde{{\bm{u}}},v\notin\tilde{{ \bm{u}}}\qquad\text{and}\qquad c(u_{i})\neq c(u_{j})\quad\forall u_{i},u_{j} \in\tilde{{\bm{u}}},u_{i}\neq u_{j}.$ $$

Note that initial colorings satisfying this property are equivalent to the initializations of HC-MPNNs. As a direct consequence of Theorem 4.1 we obtain (see Appendix F):

###### Theorem 5.1 .

Let $G=(V,E,R,c)$ be a relational hypergraph and ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$ be a query such that $c$ satisfies generalized target node distinguishability with respect to ${\bm{q}}$. Then the following statements hold:

- 1.
For all HC-MPNNs with $L$ layers and initialization
Init with
$\textsc{Init}\equiv c$, $0\leq\ell\leq L$, we have
${\sf hrwl}_{1}^{(\ell)}\preceq{\bm{h}}_{\bm{q}}^{(\ell)}$.
- 2.
For all $L\geq 0$, there is an HC-MPNN with $L$ layers
s.t.
$0\leq\ell\leq L$,
${\sf hrwl}_{1}^{(\ell)}\equiv{\bm{h}}_{\bm{q}}^{(\ell)}$ holds.

Theorem 5.1 tells us that HC-MPNNs are stronger than HR-MPNNs due to the initialization: HC-MPNNs can initialize nodes differently based on the query ${\bm{q}}$, whereas HR-MPNNs always assign the same initialization for all queries. In fact, the ternary edges from Figure 2 cannot be distinguished by HR-MPNNs but they can be distinguished by HC-MPNNs.

###### Theorem 5.1 .

### 5.3 Logical expressiveness of HC-MPNNs

We remark that Theorem 4.3 can be translated to HC-MPNNs by slightly modifying the logic. We consider *symbolic* queries ${\bm{q}}=(q,\tilde{{\bm{b}}},t)$, where now each $b\in\tilde{{\bm{b}}}$ is a constant symbol. Our vocabulary contains relation types $r\in R$ and node colors ${\cal C}$, as before, and additionally the constants $b\in\tilde{{\bm{b}}}$.
We define *hypergraph graded modal logic with constants* (HGMLc) as HGML but, as atomic cases, we additionally have formulas of the form $\varphi(x)=(x=b)$ for some constant $b$ (see Appendix G for details). This allows us to *identify* variables with individual constants.

###### Example 5.2 .

Now that we have a richer vocabulary with constants, we can now represent more formulas “conditioned” on the constants appearing in the query. For instance, given a symbolic query with $\tilde{{\bm{b}}}=(\mathsf{Physics},\mathsf{BA})$ , we can express a more complex formula $\psi(x)$ that represents “$x$ is a person with a BA degree of Physics at some University $m$, where less than two prizes $p$ in total have been awarded in Physics.”
as follows:

$$ $\displaystyle\psi(x)=\text{Person}(x)\,\land\,$ $\displaystyle\exists y,z,m\Big{(}\text{StudyDegree}(x,y,z,m)\land(z=\mathsf{ Physics})\land(y=\mathsf{BA})$ $\displaystyle\qquad\qquad\qquad\land\neg\left(\exists^{\geq 2}p,w\,\left(\text {Awarded}(w,p,m)\land(w=\mathsf{Physics})\right)\right)\Big{)}$ $$

Note that this formula $\psi(x)$ cannot be expressed as an HGML formula but it can be as an HGMLc formula, due to the additional introduction of constants. $\diamond$

We prove the following result showing that HC-MPNNs can capture richer $k$-ary node properties:

###### Theorem 5.3 .

Each HGMLc classifier can be captured by a HC-MPNN over valid relational hypergraphs.

**Table 1: Results of inductive link prediction experiments. We report MRR, Hits@$1$, and Hits@$3$ (higher is better) on test sets.**
|  | WP-IND | JF-IND | MFB-IND |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | MRR | Hits@1 | Hits@3 | MRR | Hits@1 | Hits@3 | MRR | Hits@1 | Hits@3 |
| HGNN | 0.072 | 0.045 | 0.112 | 0.102 | 0.086 | 0.128 | 0.121 | 0.076 | 0.114 |
| HyperGCN | 0.075 | 0.049 | 0.111 | 0.099 | 0.088 | 0.133 | 0.118 | 0.074 | 0.117 |
| G-MPNN-sum | 0.177 | 0.108 | 0.191 | 0.219 | 0.155 | 0.236 | 0.124 | 0.071 | 0.123 |
| G-MPNN-mean | 0.153 | 0.096 | 0.145 | 0.112 | 0.039 | 0.116 | 0.241 | 0.162 | 0.257 |
| G-MPNN-max | 0.200 | 0.125 | 0.214 | 0.216 | 0.147 | 0.240 | 0.268 | 0.191 | 0.283 |
| HCNet | 0.414 | 0.352 | 0.451 | 0.435 | 0.357 | 0.495 | 0.368 | 0.223 | 0.417 |

###### Example 5.2 .

###### Theorem 5.3 .

## 6 Experimental evaluation

We evaluate HCNet on a broad range of experiments, some of which are reported in the appendix:

- •
Inductive experiments (Section 6.1): We evaluate HCNet for inductive link prediction with relational hypergraphs and report very substantial improvements reflecting on our theoretical findings.
- •
Transductive experiments (Appendix K): We evaluate HCNet for transductive link prediction with relational hypergraphs and report multiple state-of-the-art results.
- •
Knowledge graph experiments (Appendix M): HCNet can handle knowledge graphs as a special case and our evaluation shows that it can match the performance of models such as NBFNets.
- •
Ablation on initialization and positional encoding (Section 6.2): We conduct ablation studies on the choice of initialization and positional encoding in HCNets.
- •
Impact of relation arity (Appendix L): To evaluate the model performance on diffferent arity relations, we report the breakdown of predictions to different arities.
- •
Expressiveness evaluation (Appendix N): We conduct a synthetic experiment on HyperCycle dataset, building on the counter-example in Figure 2 to showcase the expressivity differences between HR-MPNNs and HC-MPNNs.

Experimental setups.
In all experiments, we consider a 2-layer MLP as the decoder and adopt layer normalization and dropout in all layers before applying ReLU activation and skip-connection.
During the training, we remove edges that are currently being treated as positive tuples to prevent overfitting for each batch. We choose the best checkpoint based on its evaluation of the validation set.
In terms of evaluation, we adopt *filtered ranking protocol*. For each test edge $q(u_{1},\ldots,u_{k})$ where $k={\textsf{ar}}(q)$, and for each position $t\in\{1,...,k\}$, we replace the $t$-th entities by all other possible entities such that the query after replacement is not in the graph. We report Mean Reciprocal Rank (MRR), Hits@$1$, and Hits@$3$ as evaluation metrics and provide averaged results of *five* runs on different seeds. We reported standard deviations and execution time & memory used along with all other experiment details in Appendix O. Furthermore, we provide a detailed discussion of computational complexity between HR-MPNNs and HC-MPNNs in Table 4. We ran all inductive experiments on a single NVIDIA V100 GPU. The code for experiments is provided in [https://anonymous.4open.science/r/HCNet](https://anonymous.4open.science/r/HCNet).

### 6.1 Inductive experiments

Datasets. Yadati [] constructed three inductive datasets, WP-IND, JF-IND, and MFB-IND from existing transductive datasets on relational hypergraphs: Wikipeople [], JF17K [], and M-FB15K [], respectively. We report their statistics in Table 10, Appendix O.

Baselines. We compare with the baseline models HGNN [], HyperGCN [], and three variants of G-MPNN [] with different aggregation functions.
Since HGNN and HyperGCN are designed for simple hypergraphs, Yadati [] tested them on transformed relational hypergraphs where the relations are ignored. In addition, Yadati [] initialized nodes with given node features, whereas we ignore the node feature and initialize each node with the respective initialization defined in HCNets. We adopt the query-independent message function,
and the *batching trick* on MFB-IND following Zhu et al. [].
All the hyper-parameter considered is reported in Table 12, Appendix O.

Results.
We report the inductive experiments results in Table 1, and observe that HCNet outperforms all the existing baseline methods by a large margin, doubling the metric on WP-IND and JF-IND and substantially increasing on MFB-IND. Notably, we emphasize that HCNet does not utilize the provided node features whereas other baseline models do, further highlighting the effectiveness of HCNet in generalizing to entirely new graphs in the absence of node features. This is because HCNet is more expressive by computing query-dependent $k$-ary invariants
instead of query-agnostic unary invariants in HR-MPNNs such as G-MPNNs with different aggregation functions. Overall, these results perfectly align with the main theoretical findings presented in this paper.

### 6.2 Ablation studies on the impact of initialization and positional encoding

**Table 2: Ablation on Initialization**
| Init | WP-IND | JF-IND |  |  |  |
| --- | --- | --- | --- | --- | --- |
| ${\bm{z}}_{q}$ | ${\bm{p}}_{i}$ | MRR | Hits@3 | MRR | Hits@3 |
| - | - | 0.388 | 0.421 | 0.390 | 0.451 |
| ✓ | - | 0.387 | 0.421 | 0.392 | 0.447 |
| - | ✓ | 0.394 | 0.430 | 0.393 | 0.456 |
| ✓ | ✓ | 0.414 | 0.451 | 0.435 | 0.495 |

To assess the contribution of each model component, we conduct ablation studies mainly on different choices of positional encodings and initialization functions on WP-IND and JF-IND datasets with the same empirical setup described in Section 6.1.
Complete results are reported in Appendix O.

Initialization. We conduct experiments to validate the impact of different initialization by evaluating all combinations of whether including positional encoding ${\bm{p}}_{i}$ or learnable query vectors ${\bm{z}}_{q}$.
From Table 3, we observe that both positional encoding ${\bm{p}}_{i}$ and the relation ${\bm{z}}_{q}$ are essential in the initialization, as removing either of them worsens the overall performance of HCNet. A closer look reveals that the removal of the positional encoding is more detrimental compared to removing relational embedding since the model could deduce the relation types based on implicit information such as the arity of the query relation.

Positional encoding. We also examine the importance of the choice of positional encodings, which serves as an indicator of which position the given entities lie in a hyperedge. We provide experiments on multiple choices of positional encodings and report the results in Table 3.
Empirically, we notice that the sinusoidal positional encoding produces the best results due to its ability to measure sequential dependency between neighboring entities, compared with one-hot positional encoding which assumes orthogonality among each position. We also notice that learnable embeddings do not produce better results since it is generally hard to learn a suitable embedding that respects the order of the nodes in a relation based on random initialization. Finally, constant embedding evidently performs the worst as it pays no respect to position information and treats all hyperedges with the same set of nodes in the same way regardless of the order of the nodes in these edges.

## 7 Summary, discussions, and limitations

We investigated two frameworks of relational message-passing neural networks on the task of link prediction with relational hypergraphs, namely HR-MPNNs and HC-MPNNs. Furthermore, we studied the expressive power of these two frameworks in terms of relational WL and logical expressiveness.
We then proposed a simple yet powerful model instance of HC-MPNNs called HCNet and presented its superior performance on inductive link prediction tasks, which is further supported by additional transductive link prediction and synthetic experiments. One limitation lies in the potentially high computational complexity of our approach when applying to large relational hypergraphs. Our approach is also limited to link prediction and a potential future avenue is to investigate complex query answering on fully relational data.
Our study extends the success of link prediction with knowledge graphs to relational hypergraphs where higher arity relations can be effectively modeled with GNNs, unlocking applications in fully relational structures.

## Appendix A R-MPNNs and C-MPNNs

In this section, we follow Huang et al. [] and define *relational message passing neural networks* (R-MPNNs) and *conditional message passing neural networks* (C-MPNNs). For ease of presentation, we omit the discussion regarding history functions and readout functions from Huang et al. [].

R-MPNNs. Let $G=(V,E,R,{\bm{x}})$ be a knowledge graph, where ${\bm{x}}$ is a feature map. A *relational message passing neural network* (R-MPNN) computes a sequence of feature maps ${\bm{h}}^{(\ell)}:V\to\mathbb{R}^{d(\ell)}$, for $\ell\geq 0$. For simplicity, we write ${\bm{h}}^{(\ell)}_{v}$ instead of ${\bm{h}}^{(\ell)}(v)$. For each node $v\in V$, the representations ${\bm{h}}^{(\ell)}_{v}$ are iteratively computed as:

$$ $\displaystyle{\bm{h}}_{v}^{(0)}$ $\displaystyle={\bm{x}}_{v}$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=\ \textsc{Up}\left({\bm{h}}_{v}^{(\ell)},\textsc{Agg}(\{\!\!\{ \textsc{Msg}_{r}({\bm{h}}_{w}^{(\ell)})|~{}w\in\mathcal{N}_{r}(v),r\in R\}\!\! \})\right),$ $$

where Up, Agg, and $\textsc{Msg}_{r}$ are differentiable *update*, *aggregation*, and relation-specific *message* functions, respectively, $\mathcal{N}_{r}(v):=\{u\mid r(u,v)\in E\}$ is the *neighborhood* of a node $v\in V$ relative to a relation $r\in R$.
An R-MPNN has a fixed number of layers $L\geq 0$, and then, the final node representations are given by the map ${\bm{h}}^{(L)}:V\to\mathbb{R}^{d(L)}$. The final representations can be used for node-level predictions. For link-level tasks, we use a binary decoder ${\textsc{dec}_{q}:\mathbb{R}^{d(L)}\times\mathbb{R}^{d(L)}\to{\mathbb{R}}}$, which produces a score for the likelihood of the fact $q(u,v)$, for $q\in R$.

C-MPNNs. Let $G=(V,E,R,{\bm{x}})$ be a knowledge graph, where ${\bm{x}}$ is a feature map. A *conditional message passing neural network* (C-MPNN) iteratively computes pairwise representations, relative to a fixed query $q\in R$ and a fixed node $u\in V$, as follows:

$$ $\displaystyle{\bm{h}}_{v|u,q}^{(0)}$ $\displaystyle=\textsc{Init}(u,v,q)$ $\displaystyle{\bm{h}}_{v|u,q}^{(\ell+1)}$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{v|u,q}^{(\ell)},\textsc{Agg}(\{\!\! \{\textsc{Msg}_{r}({\bm{h}}_{w|u,q}^{(\ell)},{\bm{z}}_{q})|~{}w\in\mathcal{N}_ {r}(v),r\in R\}\!\!\})\Big{)},$ $$

where Init, Up, Agg, and $\textsc{Msg}_{r}$ are differentiable *initialization*, *update*, *aggregation*, and relation-specific *message* functions, respectively.

We denote by ${\bm{h}}_{q}^{(\ell)}:V\times V\to\mathbb{R}^{d(\ell)}$ the function ${\bm{h}}_{q}^{(\ell)}(u,v):={\bm{h}}_{v|u,q}^{(\ell)}$, and denote ${\bm{z}}_{q}$ to be a learnable vector representing the query $q\in R$. A C-MPNN has a fixed number of layers $L\geq 0$, and the final pair representations are given by ${\bm{h}}_{q}^{(L)}$. To decode the likelihood of the fact $q(u,v)$ for some $q\in R$, we simply use a unary decoder $\textsc{dec}:\mathbb{R}^{d(L)}\to{\mathbb{R}}$, parameterized by a 2-layer MLP. In addition, we require $\textsc{Init}(u,v,q)$ to satisfy *target node distinguishability*: for all $q\in R$ and $v\neq u\in V$, it holds that $\textsc{Init}(u,u,q)\neq\textsc{Init}(u,v,q)$.

## Appendix B On representations of high-arity facts

We carefully distinguish between the task setting of relational hypergraphs (also known as *knowledge hypergraphs* in Fatemi et al. [, ], or *multi-relational ordered hypergraphs* in Yadati []), hyper-relational knowledge graphs, and $n$-ary relational graphs.

- •
Relational hypergraphs. A relational hypergraph is $G=(V,E,R)$, where each facts in $E$ is represented as $k$-ary tuple $r(u_{1},\cdots,u_{k})$ for $u_{1},\cdots,u_{k}\in V$ and $r\in R$. As of this work, many works [, , ] have considered this form of representation.
- •
Hyper-relational knowledge graphs. A hyper-relational knowledge graph $G=(V,E,R)$, where $R$ is a set of relation and each fact in $E$ is represented as a tuple $(u,r,v,\{\!\!\{(qr_{i},qv_{i})\mid 1\leq i\leq n\}\!\!\})$ where $u,v\in V$ with $r\in R$ is the main triplet, and $\{\!\!\{(qr_{i},qv_{i})\mid 1\leq i\leq n\}\!\!\}\in\mathcal{P}(R\times V)$ is a set of qualifier-value pairs. Note that qualifiers are also chosen from the set of relation $R$ and are used to describe the entities as the additional information stored in the knowledge graph for each triplet. Earlier research [, ] mainly investigated this form of representation.
- •
$n$-ary relational graphs. A $n$-ary relational graph $G=(V,E,C)$, where each fact in $E$ is represented by a set of role-value tuple $\{\!\!\{(r_{i},v_{i})\mid 1\leq i\leq n\}\!\!\}\in\mathcal{P}(C\times V)$, and $C$ is the set of roles, which are unary relation defined over entity for each fact, acting as additional information. Earlier study [] adopt this form of representation.

To further clarify the difference, we show an example with the following visualization for each type of graph in Figure 4. Given a high-arity fact “$\mathsf{Hawking}$ went to $\mathsf{Oxford}$ to study $\mathsf{Physics}$ and received a $\mathsf{BA}$ degree” to be captured:

- •
In relational hypergraphs, each fact is represented by a tuple (thus the ordering is fixed):
$\mathsf{StudyDegree}(\mathsf{Hawking},\mathsf{Oxford},\mathsf{Physics},\mathsf
{BA}).$
- •
In hyper-relational knowledge graphs, each fact is represented by a tuple of main triplet together with a set of qualifier-value pairs:
$(\mathsf{Hawking},\mathsf{{Received}},\mathsf{BA},\{\!\!\{{\mathsf{University}
}(\mathsf{Oxford}),{\mathsf{Subject}}(\mathsf{Physics})\}\!\!\}).$
- •
In a $n$-ary relational graphs, each fact is represented as a set (thus unordered):
$\{\!\!\{{\mathsf{Person}}(\mathsf{Hawking}),{\mathsf{University}}(\mathsf{
Oxford}),{\mathsf{Subject}}(\mathsf{Physics}),{\mathsf{Degree}}(\mathsf{BA})\}
\!\!\}.$

Thus, notice that link prediction with relational hypergraphs is a more general problem setup, where no roles and qualifiers are provided as extra information. This differs from the problem setup of link prediction with hyper-relational knowledge graphs or $n$-ary relational graphs, where the unary relations (qualifiers/roles) are also within the relation vocabulary.

Figure: Figure 4: Different ways to represent high-arity fact “$\mathsf{Hawking}$ went to $\mathsf{Oxford}$ to study $\mathsf{Physics}$ and received a $\mathsf{BA}$ degree” as hyper-edges.

## Appendix C HR-MPNNs subsume existing models

In this section, we provide further details on how the proposed framework HR-MPNNs subsumes existing models as claimed.

### C.1 HR-MPNNs subsume G-MPNNs and RD-MPNNs

To see why HR-MPNNs subsume RD-MPNNs [] and G-MPNNs [], which are prominent examples of message passing model on relational hypergraphs in the literature, it suffices to instantiate some components of HR-MPNNs with particular functions.

An RD-MPNN can be seen as an instance of an HR-MPNN that uses summation as Agg, and a relation-specific message function $\textsc{Msg}_{r}$ which, for each relation $r$, applies summation followed by a linear map with non-linearity. The update function Up is a one-layer Multi-layer Perceptron (MLP).

Similarly, a G-MPNN instance can be seen as an HR-MPNN that uses either summation, mean, or max as Agg, and a message function $\textsc{Msg}_{r}$ which, for each relation $r$, applies a *Hadamard product* of the relational embedding.

### C.2 HR-MPNNs subsuming HGNNs and HyperGCNs

To see why HR-MPNNs generalize HGNNs [] and HyperGCNs [] on simple, undirected hypergraph, first note that (i) these models are single-relational - no relation types - so they are a special case in this sense and (ii) the hyperedges in these undirected hypergraphs are unordered.

To recover HGNN, we can set the message function $\textsc{Msg}_{r}$ to be mean, ignoring the relation types $r$, and ignore the relative position in the formula (as there is no ordering in simple, undirected hypergraph). Then, we can choose the Agg function to be symmetrically normalized mean, similar to the aggregation in GCN [].

To recover HyperGCN, we set Agg to be the symmetrically normalized mean, and $\textsc{Msg}_{r}$ function to be $w_{i,j}*\operatorname*{arg\,max}_{{\bm{h}}_{j}}|{\bm{h}}_{i}-{\bm{h}}_{j}|$, with some weight $w_{i,j}$ (again ignoring the relation $r$ and position $i$), provided that the message function has access to the feature of considered node ${\bm{h}}_{i}$.

### C.3 HR-MPNNs subsume R-MPNNs

We formally show that the R-MPNNs framework is subsumed by the HR-MPNNs framework when applied to the knowledge graph.

###### Theorem C.1 .

Let $G=(V,E,R,{\bm{x}})$ be a knowledge graph, then given any R-MPNN instance $\mathcal{A}$ with $L$ layer parameterized by $\textsc{Agg}_{\mathcal{A}}^{(\ell)}$, $\textsc{Up}_{\mathcal{A}}^{(\ell)}$, and ${\textsc{Msg}_{\mathcal{A}}}_{r}$ for $0<\ell\leq L$, $r\in R$, there exists a HR-MPNN instance $\mathcal{B}$ with $L$ layer, parameterized by $\textsc{Agg}_{\mathcal{B}}^{(\ell)}$, $\textsc{Up}_{\mathcal{B}}^{(\ell)}$, and ${\textsc{Msg}_{\mathcal{B}}}_{r}$, such that for all $v\in V$, we have ${\bm{h}}_{\mathcal{A},G}^{(\ell)}(v)={\bm{h}}_{\mathcal{B},G}^{(\ell)}(v)$ for all $0\leq\ell\leq L$.

###### Proof.

Given an R-MPNN instance $\mathcal{A}$ with $L$ layer, we can have that for $0\leq\ell\leq L$, we have

$$ $\displaystyle{\bm{h}}_{\mathcal{A},G}^{(0)}(v)$ $\displaystyle={\bm{x}}(v)$ $\displaystyle{\bm{h}}_{\mathcal{A},G}^{(\ell+1)}(v)$ $\displaystyle=\ \textsc{Up}_{\mathcal{A}}^{(\ell)}\left({\bm{h}}_{\mathcal{A}, G}^{(\ell)}(v),\textsc{Agg}_{\mathcal{A}}^{(\ell)}(\{\!\!\{{\textsc{Msg}_{ \mathcal{A}}}_{r}({\bm{h}}_{\mathcal{A},G}^{(\ell)}(w))|~{}w\in\mathcal{N}_{r} (v),r\in R\}\!\!\})\right),$ $$

Note that we can now rewrite the updating formula in the following form:

$$ $\displaystyle{\bm{h}}_{\mathcal{A},G}^{(\ell+1)}(v)$ $\displaystyle=\textsc{Up}_{{\mathcal{A}}}^{(\ell)}\Big{(}{\bm{h}}_{{\mathcal{A }},G}^{(\ell)}(v),$ $\displaystyle\textsc{Agg}_{{\mathcal{A}}}^{(\ell)}\big{(}\{\!\!\{{\textsc{Msg} _{\mathcal{A}}}_{\rho(e)}\big{(}\{({\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(w),j)\! \mid\!(w,j)\in{\mathcal{N}}_{i}(e)\}\big{)}\!\mid\!(e,i)\in E(v),i=2\}\!\!\} \big{)}\Big{)}$ $$

We then parameterize a HR-MPNN instance $\mathcal{B}$ with $L$ layer of the following form:

$$ $\displaystyle{\bm{h}}_{\mathcal{B},G}^{(0)}(v)$ $\displaystyle={\bm{x}}(v)$ $\displaystyle{\bm{h}}_{\mathcal{B},G}^{(\ell+1)}(v)$ $\displaystyle=\textsc{Up}_{{\mathcal{B}}}^{(\ell)}\Big{(}{\bm{h}}_{{\mathcal{B }},G}^{(\ell)}(v),\textsc{Agg}_{{\mathcal{B}}}^{(\ell)}\big{(}{\bm{h}}_{{ \mathcal{B}},G}^{(\ell)}(v),$ $\displaystyle\qquad\qquad\{\!\!\{{\textsc{Msg}_{{\mathcal{B}}}}_{\rho(e)}\big{ (}\{({\bm{h}}_{{\mathcal{B}},G}^{(\ell)}(w),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i }(e)\}\big{)}\!\mid\!(e,i)\in E(v)\}\!\!\}\big{)}\Big{)}$ $$

where we have for all $0<\ell\leq L$, $r\in R$, $\textsc{Up}_{{\mathcal{B}}}^{(\ell)}:=\textsc{Up}_{{\mathcal{A}}}^{(\ell)}$, $\textsc{Agg}_{{\mathcal{B}}}^{(\ell)}({\bm{x}},S):=\textsc{Agg}_{{\mathcal{A}}
}^{(\ell)}(S)$, for some vector ${\bm{x}}$ and some (multi-)set $S$, and

$$ ${\textsc{Msg}_{{\mathcal{B}}}}_{\rho(e)}(\{({\bm{h}}^{(\ell)}(w),j)\!\mid\!(w, j)\in{\mathcal{N}}_{i}(e)\}):={\textsc{Msg}_{{\mathcal{A}}}}_{\rho(e)}(\{({\bm {h}}^{(\ell)}(w),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i}(e),j=1\})$ $$

We argue that ${\textsc{Msg}_{{\mathcal{B}}}}_{\rho(e)}$ can be achieved by applying a filtering function on each element of the set to check if the second argument of the tuple is $1$ or not.

Now we are ready to prove the theorem by induction.
First notice that the base case $\ell=0$ trivially holds. For the inductive case, assume that for all $v\in V$, we have ${\bm{h}}_{\mathcal{A},G}^{(\ell)}(v)={\bm{h}}_{\mathcal{B},G}^{(\ell)}(v)$. Then, notice that for $0<\ell\leq L$:

$$ $\displaystyle{\bm{h}}_{\mathcal{A},G}^{(\ell+1)}$ $\displaystyle(v)=\textsc{Up}_{{\mathcal{A}}}^{(\ell)}\Big{(}{\bm{h}}_{{ \mathcal{A}},G}^{(\ell)}(v),$ $\displaystyle\qquad\qquad\textsc{Agg}_{{\mathcal{A}}}^{(\ell)}\big{(}\{\!\!\{{ \textsc{Msg}_{\mathcal{A}}}_{\rho(e)}\big{(}\{({\bm{h}}_{{\mathcal{A}},G}^{( \ell)}(w),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i}(e)\}\big{)}\!\mid\!(e,i)\in E(v) ,i=2\}\!\!\}\big{)}\Big{)}$ $\displaystyle=\textsc{Up}_{{\mathcal{A}}}^{(\ell)}\Big{(}{\bm{h}}_{{\mathcal{A }},G}^{(\ell)}(v),$ $\displaystyle\qquad\qquad\textsc{Agg}_{{\mathcal{A}}}^{(\ell)}\big{(}\{\!\!\{{ \textsc{Msg}_{\mathcal{A}}}_{\rho(e)}\big{(}\{({\bm{h}}_{{\mathcal{A}},G}^{( \ell)}(w),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i}(e),j=1\}\big{)}\!\mid\!(e,i)\in E (v),i=2\}\!\!\}\big{)}\Big{)}$ $\displaystyle=\textsc{Up}_{{\mathcal{B}}}^{(\ell)}\Big{(}{\bm{h}}_{{\mathcal{B }},G}^{(\ell)}(v),\textsc{Agg}_{{\mathcal{B}}}^{(\ell)}\big{(}{\bm{h}}_{{ \mathcal{B}},G}^{(\ell)}(v),$ $\displaystyle\qquad\qquad\{\!\!\{{\textsc{Msg}_{{\mathcal{B}}}}_{\rho(e)}\big{ (}\{({\bm{h}}_{{\mathcal{B}},G}^{(\ell)}(w),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i }(e)\}\big{)}\!\mid\!(e,i)\in E(v)\}\!\!\}\big{)}\Big{)}$ $\displaystyle={\bm{h}}_{\mathcal{B},G}^{(\ell+1)}(v)$ $$

###### Remark C.2 .

Note that analogously we can show that HC-MPNNs subsumes C-MPNNs by noticing *generalized target node distinguishability* in HC-MPNNs degrades to *target node distinguishability* in the context of knowledge graph. See further detailed discussion in Appendix H.

∎

###### Theorem C.1 .

###### Proof.

###### Remark C.2 .

## Appendix D Proof of Theorem 4.1

###### Theorem 4.1 .

Let $G=(V,E,R,c)$ be a relational hypergraph, then the following statements hold:

- 1.
For all initial feature maps ${\bm{x}}$ with $c\equiv{\bm{x}}$, all HR-MPNNs with $L$ layers, and for all $0\leq\ell\leq L$, it holds that ${\sf hrwl}_{1}^{(\ell)}\preceq{\bm{h}}^{(\ell)}$.
- 2.
For all $L\geq 0$, there is an initial feature map ${\bm{x}}$ with $c\equiv{\bm{x}}$ and an HR-MPNN with $L$ layers, such that for all $0\leq\ell\leq L$, we have ${\sf hrwl}_{1}^{(\ell)}\equiv{\bm{h}}^{(\ell)}$.

###### Proof.

First, for simplicity of notation, we define ${\bm{m}}^{(\ell)}_{e,i}=\textsc{Msg}_{\rho(e)}\Big{(}\{({\bm{h}}_{w}^{(\ell)},
j)\mid(w,j)\in{\mathcal{N}}_{i}(e)\}\Big{)}$ for edge $e$, position $1\leq i\leq{\textsf{ar}}(\rho(e))$, and $\ell\geq 0$.

To prove item (1), we first take an initial feature map ${\bm{x}}$ with $c\equiv{\bm{x}}$ and a HR-MPNN with $L$ layers. We apply induction on $\ell$. The base case where $\ell=0$ follows directly as ${\sf hrwl}_{1}^{(0)}\equiv c\equiv{\bm{x}}\equiv{\bm{h}}^{(0)}$. For the inductive case, assume ${\sf hrwl}_{1}^{(\ell+1)}(u)={\sf hrwl}_{1}^{(\ell+1)}(v)$ for some node pair $u,v\in V$ and for some $\ell\geq 1$. By injectivity of $\tau$, it follows that ${\sf hrwl}_{1}^{(\ell)}(u)={\sf hrwl}_{1}^{(\ell)}(v)$ and

$$ $\displaystyle\{\!\!\{(\{({\sf hrwl}_{1}^{(\ell)}(w),j)\mid(w,j)\in{\mathcal{N} }_{i}(e)\},\rho(e))\mid(e,i)\in E(u)\}\!\!\}=$ $\displaystyle\{\!\!\{(\{({\sf hrwl}_{1}^{(\ell)}(w),j)\mid(w,j)\in{\mathcal{N} }_{i^{\prime}}(e^{\prime})\},\rho(e^{\prime}))\mid(e^{\prime},i^{\prime})\in E (v)\}\!\!\}$ $$

By inductive hypothesis, we have ${\bm{h}}_{u}^{(\ell)}={\bm{h}}_{v}^{(\ell)}$ and

$$ $\displaystyle\{\!\!\{(\{({\bm{h}}_{w}^{(\ell)},j)\mid(w,j)\in{\mathcal{N}}_{i} (e)\},\rho(e))\mid(e,i)\in E(u)\}\!\!\}=$ $\displaystyle\{\!\!\{(\{({\bm{h}}_{w}^{(\ell)},j)\mid(w,j)\in{\mathcal{N}}_{i^ {\prime}}(e^{\prime})\},\rho(e^{\prime}))\mid(e^{\prime},i^{\prime})\in E(v)\} \!\!\}.$ $$

Thus we have

$$ $\displaystyle\{\!\!\{\textsc{Msg}_{\rho(e)}^{(\ell)}\Big{(}\{({\bm{h}}_{w}^{( \ell)},j)\mid(w,j)\in{\mathcal{N}}_{i}(e)\}\Big{)}\mid(e,i)\in E(u)\}\!\!\}=$ $\displaystyle\{\!\!\{\textsc{Msg}_{\rho(e^{\prime})}^{(\ell)}\Big{(}\{({\bm{h} }_{w}^{(\ell)},j)\mid(w,j)\in{\mathcal{N}}_{i^{\prime}}(e^{\prime})\}\Big{)} \mid(e^{\prime},i^{\prime})\in E(v)\}\!\!\}$ $$

and then:

$$ $\displaystyle\{\!\!\{{\bm{m}}_{e,i}^{(\ell)}\mid(e,i)\in E(u)\}\!\!\}$ $\displaystyle=\{\!\!\{{\bm{m}}_{e^{\prime},i^{\prime}}^{(\ell)}\mid(e^{\prime} ,i^{\prime})\in E(v)\}\!\!\}.$ $$

We thus conclude that

$$ $\displaystyle{\bm{h}}_{u}^{(\ell+1)}$ $\displaystyle=\textsc{Up}^{(\ell)}\Big{(}{\bm{h}}_{u}^{(\ell)},\textsc{Agg} \Big{(}{\bm{h}}_{u}^{(\ell)},\{\!\!\{{\bm{m}}^{(\ell)}_{e,i}\mid(e,i)\in E(u) \}\!\!\}\Big{)}\Big{)}$ $\displaystyle=\textsc{Up}^{(\ell)}\Big{(}{\bm{h}}_{v}^{(\ell)},\textsc{Agg} \Big{(}{\bm{h}}_{v}^{(\ell)},\{\!\!\{{\bm{m}}^{(\ell)}_{e^{\prime},i^{\prime}} \mid(e^{\prime},i^{\prime})\in E(v)\}\!\!\}\Big{)}\Big{)}$ $\displaystyle={\bm{h}}_{v}^{(\ell+1)}.$ $$

Now we proceed to show item (2). We use a model of HR-MPNN in the following form and show that any iteration of ${\sf hrwl}_{1}$ can be simulated by a specific layer of such instance of HR-MPNN:

$$ $\displaystyle{\bm{h}}_{v}^{(0)}$ $\displaystyle={\bm{x}}_{v}$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=f^{(\ell)}\Big{(}\Big{[}{\bm{h}}_{v}^{(\ell)}\Big{\|}\sum_{(e,i) \in E(v)}g_{\rho(e)}^{(\ell)}\Big{(}\odot_{j\neq i}({\bm{h}}_{e(j)}^{(\ell)}+{ \bm{p}}_{j})\Big{)}\Big{]}\Big{)}.$ $$

Here, $f^{(\ell)}({\bm{z}})=\operatorname{sign}({\bm{W}}^{(\ell)}{\bm{z}}-{\bm{b}})$ where ${\bm{W}}^{(\ell)}$ is a parameter matrix, ${\bm{b}}$ is the bias term, in this case the all-ones vector ${\bm{b}}=(1,\dots,1)^{T}$, and as non-linearity we use the sign function $\operatorname{sign}$. For a relation type $r\in R$, the function $g_{r}^{(\ell)}$ has the form $g_{r}^{(\ell)}({\bm{z}})={\bm{Y}}_{r}^{(\ell)}\operatorname{sign}({\bm{W}}_{r}
^{(\ell)}{\bm{z}}-{\bm{b}})$, where ${\bm{W}}_{r}^{(\ell)}$ and ${\bm{Y}}_{r}^{(\ell)}$ are parameter matrices and ${\bm{b}}$ is the all-ones bias vector. Recall that $\odot$ denotes element-wise multiplication and ${\bm{p}}_{j}$ is the positional encoding at position $j$, which in this case is a parameter vector.

We shall use the following lemma shown in Morris et al. [][Lemma 9]. The matrix ${\bm{J}}$ denotes the all-ones matrix (with appropriate dimensions).

###### Lemma D.1 ( [ 22 ] ) .

Let ${\bm{B}}\in\mathbb{N}^{s\times t}$ be a matrix whose columns are pairwise distinct.
Then there is a matrix ${\bm{X}}\in\mathbb{R}^{t\times s}$ such that the matrix $\operatorname{sign}({\bm{X}}{\bm{B}}-{\bm{J}})\in\{-1,1\}^{t\times t}$ is non-singular.

For a matrix ${\bm{B}}$, we denote by ${\bm{B}}_{i}$ its $i$-th column. Let $n=|V|$ and without loss of generality assume $V=\{1,\dots,n\}$. Let $m$ be the maximum arity over all edges of $G$. We will write feature maps ${\bm{h}}:V\to\mathbb{R}^{d}$ for $G=(V,E,R,c)$ also as matrices ${\bm{H}}\in\mathbb{R}^{d\times n}$, where the column ${\bm{H}}_{v}$ corresponds to the $d$-dimensional feature vector for node $v$.

Let $\bm{Fts}$ be the following $nm\times n$ matrix:

$$ $\bm{Fts}=\begin{bmatrix}-1&-1&\cdots&-1&-1\\ \vdots&\vdots&\vdots&\vdots&\vdots\\ -1&-1&\cdots&-1&-1\\ 1&-1&\cdots&-1&-1\\ \vdots&\vdots&\vdots&\vdots&\vdots\\ 1&-1&\cdots&-1&-1\\ \vdots&\ddots&\ddots&\ddots&\vdots\\ 1&1&\cdots&1&-1\\ \vdots&\vdots&\vdots&\vdots&\vdots\\ 1&1&\cdots&1&-1\end{bmatrix}$ $$

That is, $(\bm{Fts})_{ij}=-1$ if $m\times j\geq i$, and $(\bm{Fts})_{ij}=1$ otherwise.
We shall use the columns of $\bm{Fts}$ as node features in our simulation.
The following lemma is a simple variation of Lemma A.5 from Huang et al. [], which in turn is a variation of Lemma D.1 above.

###### Lemma D.2 .

Let ${\bm{B}}\in\mathbb{N}^{s\times t}$ be a matrix such that $t\leq n$, and all the columns are pairwise distinct and different from the all-zeros column. Then there is a matrix ${\bm{X}}\in\mathbb{R}^{nm\times s}$ such that the matrix $\operatorname{sign}({\bm{X}}{\bm{B}}-{\bm{J}})\in\{-1,1\}^{nm\times t}$ is precisely the sub-matrix of $\bm{Fts}$ given by its first $t$ columns.

###### Proof.

Let ${\bm{z}}=(1,k+1,(k+1)^{2},\dots,(k+1)^{s-1})\in\mathbb{N}^{1\times s}$, where $k$ is the largest entry in ${\bm{B}}$, and ${\bm{b}}={\bm{z}}{\bm{B}}\in\mathbb{N}^{1\times t}$. By construction, the entries of ${\bm{b}}$ are positive and pairwise distinct. Without loss of generality, we assume that ${\bm{b}}=(b_{1},b_{2},\dots,b_{t})$ for $b_{1}>b_{2}>\cdots>b_{t}>0$. As the $b_{i}$ are ordered, we can choose numbers $x_{1},\dots,x_{t}\in\mathbb{R}$ such that $b_{i}\cdot x_{j}<1$ if $i\geq j$, and
$b_{i}\cdot x_{j}>1$ if $i<j$, for all $i,j\in\{1,\dots,t\}$. Let ${\bm{x}}=(x_{1},\dots,x_{t},2/b_{t},\dots,2/b_{t})^{T}\in\mathbb{R}^{n\times 1}$. Note that $(2/b_{t})\cdot b_{i}>1$, for all $i\in\{1,\dots,t\}$. Let ${\bm{x}}^{\prime}=({\bm{x}}_{1},\dots,{\bm{x}}_{1},{\bm{x}}_{2},\dots,{\bm{x}}
_{2},\dots,{\bm{x}}_{n},\dots,{\bm{x}}_{n})^{T}\in\mathbb{R}^{nm\times 1}$ be the vector obtained from ${\bm{x}}$ by replacing each entry ${\bm{x}}_{i}$ with $m$ consecutive copies of ${\bm{x}}_{i}$. Then $\operatorname{sign}({\bm{x}}^{\prime}{\bm{b}}-{\bm{J}})$ is precisely the sub-matrix of $\bm{Fts}$ given by its first $t$ columns. We can choose ${\bm{X}}={\bm{x}}^{\prime}{\bm{z}}\in\mathbb{R}^{nm\times s}$.
∎

We conclude item (2) by showing the following lemma:

###### Lemma D.3 .

There exist a family of feature maps $\{{\bm{h}}^{(\ell)}:V\to\mathbb{R}^{nm}\mid 0\leq\ell\leq L\}$, family of matrices $\{{\bm{W}}^{(\ell)}\mid 0\leq\ell<L\}$ and $\{\{{\bm{W}}_{r}^{(\ell)},{\bm{Y}}_{r}^{(\ell)}\}\mid 0\leq\ell<L,r\in R\}$, and positional encodings $\{{\bm{p}}_{j}\mid 1\leq j\leq m\}$ such that:

- •
${\bm{h}}^{(\ell)}\equiv{\sf hrwl}_{1}^{(\ell)}$ for all $0\leq\ell\leq L$.
- •
${\bm{h}}_{v}^{(\ell)}\in\mathbb{R}^{nm}$ is a column of $\bm{Fts}$ for all $0\leq\ell\leq L$ and $v\in V$.
- •
${\bm{h}}_{v}^{(\ell+1)}=f^{(\ell)}\Big{(}\Big{[}{\bm{h}}_{v}^{(\ell)}\Big{\|}
\sum_{(e,i)\in E(v)}g_{\rho(e)}^{(\ell)}\Big{(}\odot_{j\neq i}({\bm{h}}_{e(j)}
^{(\ell)}+{\bm{p}}_{j})\Big{)}\Big{]}\Big{)}$ for all $0\leq\ell<L$ and $v\in V$, where $f^{(\ell)}$ and $g_{r}^{(\ell)}$ are defined as above, i.e. $f^{(\ell)}({\bm{z}})=\operatorname{sign}({\bm{W}}^{(\ell)}{\bm{z}}-{\bm{b}})$ and $g_{r}^{(\ell)}({\bm{z}})={\bm{Y}}_{r}^{(\ell)}\operatorname{sign}({\bm{W}}_{r}
^{(\ell)}{\bm{z}}-{\bm{b}})$ (vector ${\bm{b}}$ is the all-ones vector).

###### Proof.

We proceed by induction on $\ell$. Suppose that the node coloring ${\sf hrwl}_{1}^{(0)}\equiv c$ with colors $1,\dots,p$, for $p\leq n$. Then we choose ${\bm{h}}^{(0)}$ such that ${\bm{h}}^{(0)}_{v}=\bm{Fts}_{c(v)}$, i.e., ${\bm{h}}^{(0)}_{v}$ is the $c(v)$-th column of $\bm{Fts}$. Thus, ${\bm{h}}^{(0)}$ satisfies the required conditions.

For the inductive case, assume that ${\bm{h}}^{(\ell)}\equiv{\sf hrwl}_{1}^{(\ell)}$ for $0\leq\ell<L$ and that ${\bm{h}}_{v}^{(\ell)}$ is a column of $\bm{Fts}$ for all $v\in V$. We shall define parameter matrices ${\bm{W}}^{(\ell)}$ and $\{\{{\bm{W}}_{r}^{(\ell)},{\bm{Y}}_{r}^{(\ell)}\}\mid r\in R\}$ and positional encodings $\{{\bm{p}}_{j}\mid 1\leq j\leq m\}$ such that the conditions of the lemma are satisfied.

For $1\leq j\leq m$, the positional encoding ${\bm{p}}_{j}$ is independent of $\ell$. Let $\tilde{{\bm{p}}}_{j}=4{\bm{b}}+8{\bm{e}}_{j}\in\mathbb{R}^{m}$, where ${\bm{b}}$ is the $m$-dimensional all-ones vector and ${\bm{e}}_{j}$ is the $m$-dimensional one-hot encoding of $j$. In other words, all entries of $\tilde{{\bm{p}}}_{j}$ are $4$ except for the $j$-th entry which is $12$. We define ${\bm{p}}_{j}=(\tilde{{\bm{p}}}_{j},\dots,\tilde{{\bm{p}}}_{j})\in\mathbb{R}^{nm}$ to be the concatenation of $n$ copies of $\tilde{{\bm{p}}}_{j}$.

Let $r\in R$ and define $E^{pos}_{r}=\{(e,i)\mid e\in E,\rho(e)=r,1\leq i\leq{\textsf{ar}}(r)\}$. For $(e,i)\in E^{pos}_{r}$, define

$$ ${\bm{o}}_{e,i}^{(\ell)}=\odot_{j\neq i}({\bm{h}}_{e(j)}^{(\ell)}+{\bm{p}}_{j}) \qquad\qquad\widetilde{\mathsf{col}}_{e,i}^{(\ell)}=\{({\sf hrwl}_{1}^{(\ell)} (w),j)\!\mid(w,j)\in{\mathcal{N}}_{i}(e)\}.$ $$

We claim that for $(e,i),(e^{\prime},i^{\prime})\in E^{pos}_{r}$, we have

$$ ${\bm{o}}_{e,i}^{(\ell)}={\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)}\text{ if and only if }\widetilde{\mathsf{col}}_{e,i}^{(\ell)}=\widetilde{\mathsf{col}}_{e^ {\prime},i^{\prime}}^{(\ell)}.$ $$

Suppose first that $\widetilde{\mathsf{col}}_{e,i}^{(\ell)}=\widetilde{\mathsf{col}}_{e^{\prime},i
^{\prime}}^{(\ell)}$. By inductive hypothesis, we have

$$ $\{({\bm{h}}_{w}^{(\ell)},j)\!\mid(w,j)\in{\mathcal{N}}_{i}(e)\}=\{({\bm{h}}_{w }^{(\ell)},j)\!\mid(w,j)\in{\mathcal{N}}_{i^{\prime}}(e^{\prime})\}.$ $$

It follows that ${\bm{o}}_{e,i}^{(\ell)}={\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)}$.
Suppose now that $\widetilde{\mathsf{col}}_{e,i}^{(\ell)}\neq\widetilde{\mathsf{col}}_{e^{\prime
},i^{\prime}}^{(\ell)}$. We consider two cases. Assume first $i\neq i^{\prime}$. Then ${\bm{o}}_{e,i}^{(\ell)}$ and ${\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)}$ differ on the $i$-th coordinate, that is, $({\bm{o}}_{e,i}^{(\ell)})_{i}\neq({\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)})_{i}$. Indeed, note that the entries of vectors of the form ${\bm{h}}_{w}^{(\ell)}+{\bm{p}}_{j}$ are always prime numbers in $\{3,5,11,13\}$ (the entries of ${\bm{h}}_{w}^{(\ell)}$ are always in $\{-1,1\}$ by inductive hypothesis). The $i$-th coordinate of all the vector factors in the product ${\bm{o}}_{e,i}^{(\ell)}=\odot_{j\neq i}({\bm{h}}_{e(j)}^{(\ell)}+{\bm{p}}_{j})$ has value $3$, and hence $({\bm{o}}_{e,i}^{(\ell)})_{i}=3^{{\textsf{ar}}(r)-1}$. On the other hand, there exists a vector factor in the product ${\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)}=\odot_{j\neq i^{\prime}}({\bm{h}}_{e
^{\prime}(j)}^{(\ell)}+{\bm{p}}_{j})$ (the factor ${\bm{h}}_{e^{\prime}(i)}^{(\ell)}+{\bm{p}}_{i}$), whose $i$-th coordinate is $11$. Hence $({\bm{o}}_{e,i}^{(\ell)})_{i}$ and $({\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)})_{i}$ have different prime factorizations and then they are distinct. Now assume $i=i^{\prime}$. Since $\widetilde{\mathsf{col}}_{e,i}^{(\ell)}\neq\widetilde{\mathsf{col}}_{e^{\prime
},i^{\prime}}^{(\ell)}$, there must be a position $j^{*}$ such that ${\sf hrwl}_{1}^{(\ell)}(e(j^{*}))\neq{\sf hrwl}_{1}^{(\ell)}(e^{\prime}(j^{*}))$. By inductive hypothesis, ${\bm{h}}_{e(j^{*})}^{(\ell)}\neq{\bm{h}}_{e^{\prime}(j^{*})}^{(\ell)}$. Again by inductive hypothesis, we know that ${\bm{h}}_{e(j^{*})}^{(\ell)}$ and ${\bm{h}}_{e^{\prime}(j^{*})}^{(\ell)}$ are columns of $\bm{Fts}$, say w.l.o.g. the $k$-th and $k^{\prime}$-th columns, respectively, for $1\leq k<k^{\prime}\leq n$. By construction of $\bm{Fts}$, all the $m$ entries of ${\bm{h}}_{e(j^{*})}^{(\ell)}$ from coordinates $\{km+1,\dots,km+m\}$ are $1$, while these are $-1$ for ${\bm{h}}_{e^{\prime}(j^{*})}^{(\ell)}$. We claim that ${\bm{o}}_{e,i}^{(\ell)}$ and ${\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)}$ differ on the $(km+j^{*})$-th coordinate. Consider the product ${\bm{o}}_{e,i}^{(\ell)}=\odot_{j\neq i}({\bm{h}}_{e(j)}^{(\ell)}+{\bm{p}}_{j})$. The $(km+j^{*})$-th coordinate of the factor ${\bm{h}}_{e(j^{*})}^{(\ell)}+{\bm{p}}_{j^{*}}$ is 13, while it is in $\{3,5\}$ for the remaining factors. For the product ${\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)}=\odot_{j\neq i^{\prime}}({\bm{h}}_{e
^{\prime}(j)}^{(\ell)}+{\bm{p}}_{j})$,
the $(km+j^{*})$-th coordinate of the factor ${\bm{h}}_{e^{\prime}(j^{*})}^{(\ell)}+{\bm{p}}_{j^{*}}$ is 11, while it is in $\{3,5\}$ for the remaining factors. Hence $({\bm{o}}_{e,i}^{(\ell)})_{km+j^{*}}$ and $({\bm{o}}_{e^{\prime},i^{\prime}}^{(\ell)})_{km+j^{*}}$ have different prime factorizations and then they are distinct.

Let $r\in R$. It follows from the previous claim that if we interpret ${\bm{o}}^{(\ell)}$ and $\widetilde{\mathsf{col}}^{(\ell)}$ as colorings for $E_{r}^{pos}$, then these two colorings are equivalent (i.e., the produce the same partition). Let
$s_{r}$ be the number of colors involved in these colorings, and let ${\bm{o}}_{1},\dots,{\bm{o}}_{s_{r}}\in\mathbb{R}^{nm}$ be an enumeration of the distinct vectors appearing in $\{{\bm{o}}_{e,i}^{(\ell)}\mid(e,i)\in E_{r}^{pos}\}$.
Let ${\bm{S}}_{r}$ be the $(nm\times s_{r})$-matrix whose columns are ${\bm{o}}_{1},\dots,{\bm{o}}_{s_{r}}$. Fix an enumeration $r_{1},\dots,r_{|R|}$ of $R$ and define $s=\sum_{r\in R}s_{r}$. Now we are ready to define our sought
matrices ${\bm{W}}_{r}^{(\ell)}$ and ${\bm{Y}}_{r}^{(\ell)}$, for $r\in R$. We define ${\bm{W}}_{r}^{(\ell)}$ to be the $(s_{r}\times nm)$-matrix obtained from applying Lemma D.1 to the matrix ${\bm{S}}_{r}$. Let $\widetilde{{\bm{Y}}}_{r}^{(\ell)}\in\mathbb{R}^{s_{r}\times s_{r}}$ be the inverse matrix of $\operatorname{sign}({\bm{W}}_{r}^{(\ell)}{\bm{S}}_{r}-{\bm{J}})$. Suppose $r=r_{k}$ for $1\leq k\leq|R|$. Then, the matrix ${\bm{Y}}_{r}^{(\ell)}$ is the $(s\times s_{r})$-matrix defined as the vertical concatenation of the following $|R|$ matrices: ${\bm{N}}_{r_{1}},\dots,{\bm{N}}_{r_{k-1}}$, $\widetilde{{\bm{Y}}}_{r}^{(\ell)}$, ${\bm{N}}_{r_{k+1}},\dots,{\bm{N}}_{r_{|R|}}$, where ${\bm{N}}_{r^{\prime}}$ is the all-zeros $(s_{r^{\prime}}\times s_{r})$-matrix. By construction, ${\bm{Y}}_{r}^{(\ell)}\operatorname{sign}({\bm{W}}_{r}^{(\ell)}{\bm{S}}_{r}-{
\bm{J}})$ is the vertical concatenation of ${\bm{N}}_{r_{1}},\dots,{\bm{N}}_{r_{k-1}}$, ${{\bm{I}}}_{r}$, ${\bm{N}}_{r_{k+1}},\dots,{\bm{N}}_{r_{|R|}}$, where ${\bm{I}}_{r}$ is the $s_{r}\times s_{r}$ identity matrix. In particular, if we consider $g_{r}^{(\ell)}({\bm{z}})={\bm{Y}}_{r}^{(\ell)}\operatorname{sign}({\bm{W}}_{r}
^{(\ell)}{\bm{z}}-{\bm{b}})$ as in the statement of the lemma, then for each $(e,i)\in E_{r}^{pos}$, the vector ${\bm{m}}_{e,i}^{(\ell)}=g_{r}^{(\ell)}({\bm{o}}_{e,i}^{(\ell)})$ has the form ${\bm{m}}_{e,i}^{(\ell)}=(\mathbf{0}_{r_{1}},\dots,\mathbf{0}_{r_{k-1}},{\bm{c}
}_{e,i}^{(\ell)},\mathbf{0}_{r_{k+1}},\dots,\mathbf{0}_{r_{|R|}})^{T}\in\{0,1
\}^{s}$, where $\mathbf{0}_{r^{\prime}}$ is the all-zeros vector of dimension $s_{r^{\prime}}$ and ${\bm{c}}_{e,i}^{(\ell)}\in\{0,1\}^{s_{r}}$ is a one-hot encoding of edge color ${\bm{o}}_{e,i}^{(\ell)}$, or equivalently, of edge color $\widetilde{\mathsf{col}}_{e,i}^{(\ell)}$. It follows that the vector

$$ ${\bm{f}}_{v}^{(\ell)}=\sum_{(e,i)\in E(v)}g_{\rho(e)}^{(\ell)}({\bm{o}}_{e,i}^ {(\ell)})=\sum_{r\in R}\sum_{(e,i)\in E(v)\cap E_{r}^{pos}}g_{r}^{(\ell)}({\bm {o}}_{e,i}^{(\ell)})$ $$

has the form ${\bm{f}}_{v}^{(\ell)}=({\bm{a}}_{r_{1}},\dots,{\bm{a}}_{r_{|R|}})^{T}\in
\mathbb{N}^{s}$, where ${\bm{a}}_{r}$ is the $s_{r}$-dimensional vector whose entry $({\bm{a}}_{r})_{j}$, for $1\leq j\leq s_{r}$, is the number of elements $(e,i)$ in $E(v)\cap E_{r}^{pos}$ with color $j$, that is, such that ${\bm{o}}_{e,i}^{(\ell)}={\bm{o}}_{j}$. In particular, ${\bm{a}}_{r}$ is an encoding of the multiset $\{\!\!\{\widetilde{\mathsf{col}}_{e,i}^{(\ell)}\mid(e,i)\in E(v)\cap E_{r}^{
pos}\}\!\!\}$ and hence ${\bm{f}}_{v}^{(\ell)}$ is an encoding of the multiset $\{\!\!\{(\widetilde{\mathsf{col}}_{e,i}^{(\ell)},\rho(e))\mid(e,i)\in E(v)\}\!\!\}$. Note that this multiset is precisely the multiset $\{\!\!\{\mathsf{col}^{(\ell)}(e,i)\mid(e,i)\in E(v)\}\!\!\}$ from the definition of the update rule of the hypergraph relational 1-WL test. Hence, the feature map given by the concatenation $[{\bm{h}}_{v}^{(\ell)}||\ {\bm{f}}_{v}^{(\ell)}]$, for all $v\in V$, is equivalent to ${\sf hrwl}_{1}^{(\ell+1)}$.

It remains to define the function $f^{(\ell)}$, given by the parameter matrix ${\bm{W}}^{(\ell)}$, so that the feature map ${\bm{h}}^{(\ell+1)}$ satisfies the conditions of the lemma. Since the columns of $\bm{Fts}$ are independent, there exists a matrix ${\bm{M}}\in\mathbb{R}^{n\times nm}$ such that ${\bm{M}}\bm{Fts}$ is the $n\times n$ identity matrix. Since each ${\bm{h}}_{v}^{(\ell)}$, with $v\in V$, is a column of $\bm{Fts}$, then ${\bm{M}}{\bm{h}}_{v}^{(\ell)}\in\{0,1\}^{n}$ corresponds to a one-hot encoding of the column or color ${\bm{h}}_{v}^{(\ell)}$. Let ${\bm{M}}^{\prime}$ be the $(n+s)\times(nm+s)$ matrix with all entries 0 0 except for the upper-left $(n\times nm)$-submatrix which is ${\bm{M}}$, and the lower-right $(s\times s)$-submatrix which is the $(s\times s)$ identity matrix. By construction, we have ${\bm{M}}^{\prime}[{\bm{h}}_{v}^{(\ell)}||\ {\bm{f}}_{v}^{(\ell)}]=[{\bm{M}}{
\bm{h}}_{v}^{(\ell)}||\ {\bm{f}}_{v}^{(\ell)}]\in\mathbb{N}^{n+s}$. Let ${\bm{z}}_{1},\dots,{\bm{z}}_{q}$, with $q\leq n$, be the distinct vectors of the form $[{\bm{M}}{\bm{h}}_{v}^{(\ell)}||\ {\bm{f}}_{v}^{(\ell)}]$ and let ${\bm{B}}$ be the $((n+s)\times q)$-matrix whose columns are precisely ${\bm{z}}_{1},\dots,{\bm{z}}_{q}$. We can apply Lemma D.2 to ${\bm{B}}$ to obtain a matrix ${\bm{X}}\in\mathbb{R}^{nm\times(n+s)}$ such that $\operatorname{sign}({\bm{X}}{\bm{B}}-{\bm{J}})$ is the matrix given by the first $q$ columns of $\bm{Fts}$. We define our sought matrix ${\bm{W}}^{(\ell)}$ to be ${\bm{W}}^{(\ell)}={\bm{X}}{\bm{M}}^{\prime}$.
∎

∎

###### Theorem 4.1 .

###### Proof.

###### Lemma D.1 ( [ 22 ] ) .

###### Lemma D.2 .

###### Proof.

###### Lemma D.3 .

###### Proof.

## Appendix E Proof of Theorem 4.3

Fix a set of relation types $R$ and a set of node colors $\mathcal{C}$.
The *hypergraph graded modal logic* (HGML) is the fragment of FO containing the following unary formulas. Firstly, $a(x)$ for $a\in\mathcal{C}$ is a formula. Secondly, if $\varphi(x)$ and $\varphi^{\prime}(x)$ are HGML formulas, then $\neg\varphi(x)$ and $\varphi(x)\land\varphi^{\prime}(x)$ also are. Thirdly, for $r\in R$, $1\leq i\leq{\textsf{ar}}(r)$ and $N\geq 1$:

$$ $\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x, y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\Psi(\tilde{{\bm{y}}})\Big{)}$ $$

is a HGML formula, where $\tilde{{\bm{y}}}=(y_{1},\dots,y_{i-1},y_{i+1},\dots,y_{{\textsf{ar}}(r)})$ and $\Psi(\tilde{{\bm{y}}})$ is a boolean combination of HGML formulas having free variables from $\tilde{{\bm{y}}}$. Intuitively, the formula expresses that $x$ participates in at least $N$ edges $e$ at position $i$, such that the remaining nodes in $e$ satisfies $\Psi$.

Let $G=(V,E,R,c)$ be a relational hypergraph where the range of the node coloring $c$ is $\mathcal{C}$. Next, we define the semantics of HGML. We define when a node $v$ of $G$ satisfies a HGML formula $\varphi(x)$, denoted by $G\models\varphi(v)$, recursively as follows:

- •
if $\varphi(x)=a(x)$ for $a\in{\cal C}$, then $G\models\varphi(v)$ iff $a$ is the color of $v$ in $G$, i.e., $c(v)=a$.
- •
if $\varphi(x)=\neg\varphi^{\prime}(x)$, then $G\models\varphi(v)$ iff $G\not\models\varphi^{\prime}(v)$.
- •
if $\varphi(x)=\varphi^{\prime}(x)\land\varphi^{\prime\prime}(x)$, then $G\models\varphi(v)$ iff $G\models\varphi^{\prime}(v)$ and $G\models\varphi^{\prime\prime}(v)$.
- •
if $\varphi(x)=\exists^{\geq N}\tilde{{\bm{y}}}\,(r(y_{1},\dots,y_{i-1},x,y_{i+1},
\dots,y_{{\textsf{ar}}(r)})\land\Psi(\tilde{{\bm{y}}}))$ then $G\models\varphi(v)$ iff there exists at least $N$ tuples $(w_{1},\dots w_{i-1},w_{i+1},\dots,w_{{\textsf{ar}}(r)})$ of nodes of $G$ such that $r(w_{1},\dots,w_{i-1},v,w_{i+1},\dots,w_{{\textsf{ar}}(r)})$ holds in $G$ and the boolean combination $\Psi(w_{1},\dots w_{i-1},w_{i+1},\dots,w_{{\textsf{ar}}(r)})$ evaluates to true.

Before showing Theorem 4.3, we need to prove an auxiliary result.
We define a restriction of HGML, denoted by HGMLr, as follows. HGMLr is defined as HGML, except for the inductive case

$$ $\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x, y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\Psi(\tilde{{\bm{y}}})\Big{)}$ $$

where now we impose $\Psi(\tilde{{\bm{y}}})$ to be a *conjunction* of HGML formulas with different free variables, that is,

$$ $\Psi(\tilde{{\bm{y}}})=\varphi_{1}(y_{1})\land\cdots\land\varphi_{i-1}(y_{i-1} )\land\varphi_{i+1}(y_{i+1})\land\cdots\land\varphi_{{\textsf{ar}}(r)}(y_{{ \textsf{ar}}(r)}).$ $$

We have that HGML is actually equivalent to HGMLr.

###### Proposition E.1 .

Every HGML formula can be translated into an equivalent HGMLr formula.

###### Proof.

We apply induction to the formulas in HGML. The only interesting case is when the formula has the form

$$ $\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x, y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\Psi(\tilde{{\bm{y}}})\Big{)}$ $$

for $r\in R$, $1\leq i\leq{\textsf{ar}}(r)$, $N\geq 1$ and a boolean combination $\Psi(\tilde{{\bm{y}}})$ of HGML formulas. We can write $\Psi(\tilde{{\bm{y}}})$ in disjunctive normal form and since negation and conjunction are part of HGML, we can assume that $\Psi(\tilde{{\bm{y}}})$ has the form:

$$ $\Psi(\tilde{{\bm{y}}})=\bigvee_{1\leq k\leq q}\varphi^{k}_{1}(y_{1})\land \cdots\land\varphi^{k}_{i-1}(y_{i-1})\land\varphi^{k}_{i+1}(y_{i+1})\land \cdots\land\varphi^{k}_{{\textsf{ar}}(r)}(y_{{\textsf{ar}}(r)}).$ $$

For $1\leq k\leq d$ and a subset $T\subseteq\{1,\dots,i-1,i+1,\dots,{\textsf{ar}}(r)\}$, we denote by $\phi_{T}^{k}$ the formula

$$ $\phi_{T}^{k}(y_{1},\dots,y_{i-1},y_{i+1},\dots,y_{{\textsf{ar}}(r)})=\bigwedge _{a\in T}\neg\varphi_{a}^{k}(y_{a})\land\bigwedge_{a\notin T}\varphi_{a}^{k}(y _{a}).$ $$

Note that $\phi_{T}^{k}$ expresses that for the $k$-th disjunct of $\Psi$, the conjuncts $\varphi_{a}^{k}(y_{a})$ that are false are precisely those for which $a\in T$. In particular the $k$-th disjunct of $\Psi$ corresponds to $\phi_{\emptyset}^{k}$.

For $S\subseteq\{1,\dots,d\}$, and a vector ${\cal T}=(T_{k}\subseteq\{1,\dots,i-1,i+1,\dots,{\textsf{ar}}(r)\}:T_{k}\neq
\emptyset,k\notin S)$, we denote by $\Psi_{S,{\cal T}}$ the formula:

$$ $\Psi_{S,{\cal T}}(y_{1},\dots,y_{i-1},y_{i+1},\dots,y_{{\textsf{ar}}(r)})= \bigwedge_{k\in S}\phi_{\emptyset}^{k}\land\bigwedge_{k\notin S}\phi_{T_{k}}^{ k}.$ $$

$\Psi_{S,{\cal T}}$ expresses that exactly the $k$-th disjuncts for $k\in S$ are true, and each of the remaining false disjuncts for $k\notin S$ are being falsified by making false precisely the conjuncts $\varphi_{a}^{k}(y_{a})$, with $a\in T_{k}$. Since HGML contains negation and conjunction, we can write $\Psi_{S,{\cal T}}$
as a conjunction of HGML formulas with different free variables, that is:

$$ $\Psi_{S,{\cal T}}(y_{1},\dots,y_{i-1},y_{i+1},\dots,y_{{\textsf{ar}}(r)})= \alpha_{1}(y_{1})\land\cdots\land\alpha_{i-1}(y_{i-1})\land\alpha_{i+1}(y_{i+1 })\land\cdots\land\alpha_{{\textsf{ar}}(r)}(y_{{\textsf{ar}}(r)}).$ $$

Define

$$ ${\cal F}:=\{\Psi_{S,{\cal T}}\mid S\subseteq\{1,\dots,d\},S\neq\emptyset,{\cal T }=(T_{k}\subseteq\{1,\dots,i-1,i+1,\dots,{\textsf{ar}}(r)\}\mid T_{k}\neq \emptyset,k\notin S)\}.$ $$

Then by construction, we have that $\Phi$ is true iff exactly one of the formulas in $\cal{F}$ is true. It follows that

$$ $\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x, y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\Psi(\tilde{{\bm{y}}})\Big{)}$ $$

is equivalent to the HGMLr formula

$$ $\displaystyle\bigvee_{\begin{subarray}{c}(N_{S,{\cal T}}\in\mathbb{N}\mid\Psi_ {S,{\cal T}}\in{\cal F})\\ \sum_{S,{\cal T}}N_{S,{\cal T}}=N\end{subarray}}\bigwedge_{\Psi_{S,{\cal T}} \in{\cal F}}\exists^{\geq N_{S,{\cal T}}}\tilde{{\bm{y}}}\,\Big{(}r(y_{1}, \dots,y_{i-1},x,y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\widetilde{\Psi}_{{S,{ \cal T}}}(\tilde{{\bm{y}}})\Big{)}$ $$

where

$$ $\widetilde{\Psi}_{{S,{\cal T}}}(y_{1},\dots,y_{i-1},y_{i+1},\dots,y_{{\textsf{ ar}}(r)})=\tilde{\alpha}_{1}(y_{1})\land\cdots\land\tilde{\alpha}_{i-1}(y_{i-1 })\land\tilde{\alpha}_{i+1}(y_{i+1})\land\cdots\land\tilde{\alpha}_{{\textsf{ ar}}(r)}(y_{{\textsf{ar}}(r)}).$ $$

where $\tilde{\alpha}_{a}(y_{a})$ is the translation to HGMLr of the formula $\alpha_{a}(y_{a})$, which we already have by induction.
∎

Now we are ready to prove Theorem 4.3.

###### Theorem 4.3 .

Each hypergraph graded modal logic classifier is captured by a HR-MPNN.

###### Proof.

We follow a similar strategy than the logic characterizations from Barceló et al. [], Huang et al. [].
Let $\varphi(x)$ be a formula in HGML, where the vocabulary contains relation types $R$ and node colors $\mathcal{C}$. By Proposition E.1, we can assume that $\varphi(x)$ belongs to HGMLr. Let $\varphi_{1},\dots,\varphi_{L}$ be an enumeration of the subformulas of $\varphi$ such that if $\varphi_{i}$ is a subformula of $\varphi_{j}$, then $i\leq j$. In particular, $\varphi_{L}=\varphi$. We shall define an HR-MPNN $\mathcal{B}_{\varphi}$ with $L$ layers computing $L$-dimensional features in each layer. The idea is that at layer $\ell\in\{1,\dots,L\}$, the $\ell$-th component of the feature ${\bm{h}}_{v}^{(\ell)}$ is computed correctly and corresponds to $1$ if $\varphi_{\ell}$ is satisfied in node $v$, and 0 0 otherwise. We add an additional final layer that simply outputs the last component of the feature vector.

We use models of HR-MPNNs of the following form:

$$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=f^{(\ell)}\Big{(}\Big{[}{\bm{h}}_{v}^{(\ell)}\Big{\|}\sum_{(e,i) \in E(v)}g_{\rho(e)}^{(\ell)}\Big{(}\odot_{j\neq i}({\bm{p}}_{j}-{\bm{h}}_{e(j )}^{(\ell)})\Big{)}\Big{]}\Big{)}.$ $$

Here, $f^{(\ell)}({\bm{z}})=\sigma({\bm{W}}^{(\ell)}{\bm{z}}+{\bm{b}})$ where ${\bm{W}}^{(\ell)}$ is a parameter matrix, ${\bm{b}}$ is the bias term and $\sigma$ is a non-linearity. For a relation type $r\in R$, the function $g_{r}^{(\ell)}$ has the form $g_{r}^{(\ell)}({\bm{z}})={\bm{a}}_{r}-\sigma({\bm{W}}_{r}^{(\ell)}{\bm{z}})$, where ${\bm{W}}_{r}^{(\ell)}$ is a parameter matrix and ${\bm{a}}_{r}$ is a parameter vector. Recall that $\odot$ denotes element-wise multiplication and ${\bm{p}}_{j}$ is the positional encoding at position $j$, which in this case is a parameter vector. The parameter matrix ${\bm{W}}^{(\ell)}$ will be a $(L\times 2L)$-matrix of the form ${\bm{W}}^{(\ell)}=[{\bm{W}}_{0}^{(\ell)}\ {\bm{I}}]$, where ${\bm{W}}_{0}^{(\ell)}$ is a $(L\times L)$ parameter matrix and ${\bm{I}}$ is the $(L\times L)$ identity matrix. The parameter matrices ${\bm{W}}_{0}^{(\ell)}$ and ${\bm{W}}_{r}^{(\ell)}$ are actually layer independent and hence we omit the superscripts. Therefore, our models are of the following form:

$$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=\sigma\Big{(}{\bm{W}}_{0}{\bm{h}}_{v}^{(\ell)}+\sum_{r\in R}\sum _{\begin{subarray}{c}(e,i)\in E(v)\\ \rho(e)=r\end{subarray}}\Big{(}{\bm{a}}_{r}-\sigma({\bm{W}}_{r}\odot_{j\neq i} ({\bm{p}}_{j}-{\bm{h}}_{e(j)}^{(\ell)}))\Big{)}+{\bm{b}}\Big{)}.$ $$

For the non-linearity $\sigma$ we use the truncated ReLU function $\sigma(x)=\min(\max(0,x),1)$. Let $m$ be the maximum arity of the relations in $R$. For $1\leq j\leq m$, the positional encoding ${\bm{p}}_{j}$ is defined as follows. The dimension of ${\bm{p}}_{j}$ must be $L$ (the same as for feature vectors). We define a set of positions $I_{j}\subseteq\{1,\dots,L\}$ as follows: $k\in I_{j}$ iff there exists a subformula of $\varphi$ of the form

$$ $\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x, y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\alpha_{1}(y_{1})$ $\displaystyle\land\dots\land\alpha_{i-1}(y_{i-1})\land\alpha_{i+1}(y_{i+1}) \land\cdots\land\alpha_{{\textsf{ar}}(r)}(y_{{\textsf{ar}}(r)})\Big{)}.$ $$

such that $j\in\{1,\dots,i-1,i+1,\dots,{\textsf{ar}}(r)\}$ and $\alpha_{j}$ is the $k$-th subformula in the enumeration $\varphi_{1},\dots,\varphi_{L}$. Then we define ${\bm{p}}_{j}$ such that $({\bm{p}}_{j})_{k}=1$ if $k\in I_{j}$ and $({\bm{p}}_{j})_{k}=3$ otherwise.

Now we define the parameter matrices ${\bm{W}}_{0}\in\mathbb{R}^{L\times L}$ and
${\bm{W}}_{r}\in\mathbb{R}^{L\times L}$, for $r\in R$, together with the bias vector ${\bm{b}}$. For $0\leq\ell<L$, the $\ell$-row of ${\bm{W}}_{0}$ and ${\bm{W}}_{r}$, and the $\ell$-th entry of ${\bm{a}}_{r}$ and ${\bm{b}}$ are defined as follows (omitted entries are 0 0):

- 1.
If $\varphi_{\ell}(x)=a(x)$ for a color $a\in\mathcal{C}$, then $({\bm{W}}_{0})_{\ell\ell}=1$.
- 2.
If $\varphi_{\ell}(x)=\neg\varphi_{k}(x)$ then $({\bm{W}}_{0})_{\ell k}=-1$, and ${\bm{b}}_{\ell}=1$.
- 3.
If $\varphi_{\ell}(x)=\varphi_{j}(x)\land\varphi_{k}(x)$ then $({\bm{W}}_{0})_{\ell j}=1$, $({\bm{W}}_{0})_{\ell k}=1$ and ${\bm{b}}_{\ell}=-1$.
- 4.
If
$\displaystyle\varphi_{\ell}(x)$
$\displaystyle=\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x
,y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\varphi_{k_{1}}(y_{1})$
$\displaystyle\land\dots\land\varphi_{k_{i-1}}(y_{i-1})\land\varphi_{k_{i+1}}(y
_{i+1})\land\cdots\land\varphi_{k_{{\textsf{ar}}(r)}}(y_{{\textsf{ar}}(r)})
\Big{)}$
then $({\bm{W}}_{r})_{\ell k_{j}}=1$ for $j\in\{1,\dots,i-1,i+1,\dots,{\textsf{ar}}(r)\}$ and $({\bm{a}}_{r})_{\ell}=1$ and ${\bm{b}}_{\ell}=-N+1$.

Let $G=(V,E,R,c)$ be a relational hypergraph with node colors from $\mathcal{C}$.
In order to apply $\mathcal{B}_{\varphi}$ to $G$,
we choose initial $L$-dimensional features ${\bm{h}}_{v}^{(0)}$ such that $({\bm{h}}_{v}^{(0)})_{\ell}=1$ if $\varphi_{\ell}=a(x)$ and $a$ is the color of $v$, and $({\bm{h}}_{v}^{(0)})_{\ell}=0$ otherwise. In other words, the $L$-dimensional initial feature ${\bm{h}}_{v}^{(0)}$ is a one-hot encoding of the color of $v$. To conclude the theorem we show by induction the following statement:

($\dagger$) *For all $1\leq\ell\leq L$, all $1\leq p\leq\ell$, all $v\in V$, we have $({\bm{h}}^{(\ell)}_{v})_{p}=1$ if and only if $G\models\varphi_{p}(v)$.*

We start by showing the following:

($\star$) *For all $1\leq\ell\leq L$, all $v\in V$, and all $1\leq p\leq L$ such that $\varphi_{p}(x)=a(x)$ for some $a\in{\cal C}$, we have $({\bm{h}}^{(\ell)}_{v})_{p}=1$ if and only if $G\models\varphi_{p}(v)$.*

We apply induction on $\ell$. For the base case assume $\ell=1$. Take $v\in V$ and $1\leq p\leq L$ such that $\varphi_{p}(x)=a(x)$ for some $a\in{\cal C}$. By construction, we have that:

$$ $\displaystyle({\bm{h}}_{v}^{(1)})_{p}$ $\displaystyle=\sigma\Big{(}({\bm{h}}_{v}^{(0)})_{p}\Big{)}=({\bm{h}}_{v}^{(0)} )_{p}.$ $$

By definition of ${\bm{h}}^{(0)}$, we obtain that $({\bm{h}}^{(1)}_{v})_{p}=1$ if and only if $G\models\varphi_{p}(v)$. For the inductive case, suppose $\ell>1$ and take $v\in V$ and $1\leq p\leq L$ such that $\varphi_{p}(x)=a(x)$ for some $a\in{\cal C}$. We have that:

$$ $\displaystyle({\bm{h}}_{v}^{(\ell)})_{p}$ $\displaystyle=\sigma\Big{(}({\bm{h}}_{v}^{(\ell-1)})_{p}\Big{)}=({\bm{h}}_{v}^ {(\ell-1)})_{p}.$ $$

By inductive hypothesis we know that $({\bm{h}}^{(\ell-1)}_{v})_{p}=1$ if and only if $G\models\varphi_{p}(v)$. It follows that $({\bm{h}}^{(\ell)}_{v})_{p}=1$ if and only if $G\models\varphi_{p}(v)$.

We now prove statement ($\dagger$).
We start with the base case $\ell=1$. Take $v\in V$. It must be the case that $p=1$ and hence $\varphi_{p}(x)=a(x)$ for some $a\in{\cal C}$. The result follows from ($\star$).

For the inductive case, take $\ell>1$. Take $v\in V$ and $1\leq p\leq\ell$. We consider several cases:

- •
Suppose $\varphi_{p}(x)=a(x)$ for some color $a\in{\cal C}$. Then the result follows from ($\star$).
- •
Suppose that $\varphi_{p}(x)=\neg\varphi_{k}(x)$. We have that:
$\displaystyle({\bm{h}}_{v}^{(\ell)})_{p}$
$\displaystyle=\sigma\Big{(}-({\bm{h}}_{v}^{(\ell-1)})_{k}+1\Big{)}=-({\bm{h}}_
{v}^{(\ell-1)})_{k}+1.$
We obtain that $({\bm{h}}_{v}^{(\ell)})_{p}=1$ iff $({\bm{h}}_{v}^{(\ell-1)})_{k}=0$. Since $k\leq\ell-1$, we have by inductive hypothesis that $({\bm{h}}_{v}^{(\ell-1)})_{k}=1$ iff $G\models\varphi_{k}(v)$. It follows that $({\bm{h}}_{v}^{(\ell)})_{p}=1$ iff $G\models\varphi_{p}(v)$.
- •
Suppose that $\varphi_{p}(x)=\varphi_{j}(x)\land\varphi_{k}(x)$. Then:
$\displaystyle({\bm{h}}_{v}^{(\ell)})_{p}$
$\displaystyle=\sigma\Big{(}({\bm{h}}_{v}^{(\ell-1)})_{j}+({\bm{h}}_{v}^{(\ell-
1)})_{k}-1\Big{)}.$
We obtain that $({\bm{h}}_{v}^{(\ell)})_{p}=1$ iff $({\bm{h}}_{v}^{(\ell-1)})_{j}=1$ and $({\bm{h}}_{v}^{(\ell-1)})_{k}=1$. Since $j,k\leq\ell-1$, we have by inductive hypothesis that $({\bm{h}}_{v}^{(\ell-1)})_{j}=1$ iff $G\models\varphi_{j}(v)$ and $({\bm{h}}_{v}^{(\ell-1)})_{k}=1$ iff $G\models\varphi_{k}(v)$. It follows that $({\bm{h}}_{v}^{(\ell)})_{p}=1$ iff $G\models\varphi_{p}(v)$.
- •
Suppose that
$\displaystyle\varphi_{p}(x)=$
$\displaystyle\exists^{\geq N}\tilde{{\bm{y}}}\,\Big{(}r(y_{1},\dots,y_{i-1},x,
y_{i+1},\dots,y_{{\textsf{ar}}(r)})\land\varphi_{k_{1}}(y_{1})$
$\displaystyle\land\dots\land\varphi_{k_{i-1}}(y_{i-1})\land\varphi_{k_{i+1}}(y
_{i+1})\land\cdots\land\varphi_{k_{{\textsf{ar}}(r)}}(y_{{\textsf{ar}}(r)})
\Big{)}.$
Then:
$\displaystyle({\bm{h}}_{v}^{(\ell)})_{p}$
$\displaystyle=\sigma\Big{(}\sum_{\begin{subarray}{c}(e,q)\in E(v)\\
\rho(e)=r\end{subarray}}\Big{(}1-\sigma\big{(}\sum_{j\neq i}\odot_{t\neq q}({
\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}\big{)}\Big{)}-N+1\Big{)}.$
We say that a pair $(e,q)\in E(v)$, with $\rho(e)=r$, is *good* if $q=i$ and $G\models\varphi_{k_{j}}(e(j))$ for all $j\in\{1,\dots,i-1,i+1,\dots,{\textsf{ar}}(r)\}$. We claim that $\sum_{j\neq i}\odot_{t\neq q}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}=0$ if $(e,q)$ is good and $\sum_{j\neq i}\odot_{t\neq q}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}>1$ otherwise.
Suppose $(e,q)$ is good. Then $q=i$. Take $j\neq i$. We have that $\odot_{t\neq i}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}=0$ since the factor $({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}=0$ when $t=j$. Indeed, by construction, $({\bm{p}}_{j})_{k_{j}}=1$. Also, since $k_{j}\leq\ell-1$, we have by inductive hypothesis that $({\bm{h}}_{e(j)}^{(\ell-1)})_{k_{j}}=1$ iff $G\models\varphi_{k_{j}}(e(j))$. Since $(e,q)$ is good, it follows that $({\bm{h}}_{e(j)}^{(\ell-1)})_{k_{j}}=1$. Hence $({\bm{p}}_{j}-{\bm{h}}_{e(j)}^{(\ell-1)})_{k_{j}}=0$. Suppose now that $(e,q)$ is not good. Assume first that $q=i$. Then there exists $j\neq i$ such that $G\not\models\varphi_{k_{j}}(e(j))$. We have that $\odot_{t\neq i}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}>1$. If $t=j$, then we have $({\bm{p}}_{t})_{k_{j}}=1$. Since $k_{j}\leq\ell-1$, by inductive hypothesis we have that $({\bm{h}}_{e(j)}^{(\ell-1)})_{k_{j}}=1$ iff $G\models\varphi_{k_{j}}(e(j))$. It follows that $({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}=1$ when $t=j$. If $t\notin\{i,j\}$, then $({\bm{p}}_{t})_{k_{j}}=3$ and then $({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}>1$. Hence $\odot_{t\neq i}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}>1$. Suppose now that $q\neq i$. Then we can choose $j=q$ and obtain that
$\odot_{t\neq q}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{j}}>1$. Indeed, we have $({\bm{p}}_{t})_{k_{q}}=3$ for all $t\neq q$. Hence all the factors of $\odot_{t\neq q}({\bm{p}}_{t}-{\bm{h}}_{e(t)}^{(\ell-1)})_{k_{q}}$ are $>1$ and then the product is $>1$.
As a consequence of the previous claim, we have that:
$\displaystyle({\bm{h}}_{v}^{(\ell)})_{p}$
$\displaystyle=\sigma\Big{(}|\{(e,i)\in E(v)\mid\rho(e)=r,\text{$(e,i)$ is good
}\}|-N+1\Big{)}.$
By definition $G\models\varphi_{p}(v)$ iff $|\{(e,i)\in E(v)\mid\rho(e)=r,\text{$(e,i)$ is good}\}|\geq N$. Hence $G\models\varphi_{p}(v)$ iff $({\bm{h}}_{v}^{(\ell)})_{p}=1$.

∎

###### Proposition E.1 .

###### Proof.

###### Theorem 4.3 .

###### Proof.

## Appendix F Proof of Theorem 5.1

###### Theorem 5.1 .

Let $G=(V,E,R,c)$ be a relational hypergraph and ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$ be a query such that $c$ satisfies target node distinguishability with respect to ${\bm{q}}$. Then the following statements hold:

- 1.
For all HC-MPNNs with $L$ layers and initialization
Init with
$\textsc{Init}\equiv c$, $0\leq\ell\leq L$, we have
${\sf hrwl}_{1}^{(\ell)}\preceq{\bm{h}}_{\bm{q}}^{(\ell)}$.
- 2.
For all $L\geq 0$, there is an HC-MPNN with $L$ layers
s.t.
$0\leq\ell\leq L$,
${\sf hrwl}_{1}^{(\ell)}\equiv{\bm{h}}_{\bm{q}}^{(\ell)}$ holds.

###### Proof.

Note that given $G$ and ${\bm{q}}$, each HC-MPNN ${\cal A}$ with $L$ layers can be translated into a HR-MPNN ${\cal B}$ with $L$ layers that produce the same node features in each layer: for ${\cal B}$ we choose as initial features, the features obtained from the initialization function of ${\cal A}$, and use the same architecture of ${\cal A}$ (functions $\textsc{Up},\textsc{Agg},\textsc{Msg}$). On the other hand, each HR-MPNN ${\cal B}$ with $L$ layers whose initial features define a coloring that satisfies generalized target node distinguishability with respect to ${\bm{q}}$ can be translated into a HC-MPNN ${\cal A}$ with $L$ layers that compute the same node features in each layer: we can define the initialization function of $\cal{A}$ so that we obtain the initial features of ${\cal B}$ and then use the same architecture of ${\cal B}$.

Item (1) is obtained by translating the given HC-MPNN into its correspondent HR-MPNN and then invoking Theorem 4.1. Similarly, item (2) is obtained by applying Theorem 4.1 to obtain an equivalent HR-MPNN and then translate it to a HC-MPNN.
∎

###### Theorem 5.1 .

###### Proof.

## Appendix G Proof of Theorem 5.3

We consider *symbolic* queries ${\bm{q}}=(q,\tilde{{\bm{b}}},t)$, where each $b\in\tilde{{\bm{b}}}$ is a constant symbol. We consider vocabularies containing relation types $r\in R$, node colors ${\cal C}$, and the constants $b\in\tilde{{\bm{b}}}$. In this case, we work with relational hypergraphs $G=(V,E,R,c,(v_{b})_{b\in\tilde{{\bm{b}}}})$, where the range of the coloring $c$ is ${\cal C}$ and $v_{b}$ is the interpretation of constant $b$. We only focus on *valid* relational hypergraphs, that is, $G=(V,E,R,c,(v_{b})_{b\in\tilde{{\bm{b}}}})$ such that for all $b,b^{\prime}\in\tilde{{\bm{b}}}$, $b\neq b^{\prime}$ implies $v_{b}\neq v_{b^{\prime}}$.

We define *hypergraph graded modal logic with constants* (HGMLc) as HGML but, as atomic cases, we additionally have formulas of the form $\varphi(x)=(x=b)$ for some constant $b$. As expected, we have that HC-MPNNs can capture HGMLc classifiers.

###### Theorem 5.3 .

Each HGMLc classifier can be captured by a HC-MPNNs over valid relational hypergraphs.

###### Proof.

The theorem follows by applying the same construction as in the proof of Theorem 4.3. Now we have extra base cases of the form $\varphi(x)=(x=b)$ but the same arguments apply. Note that now we need to define the initial features ${\bm{h}}^{(0)}$ via the initialization function of the HC-MPNN. Since we are focusing on valid relational hypergraphs, this can be easily done while satisfying generalized target node distinguishability.
∎

###### Theorem 5.3 .

###### Proof.

## Appendix H Link prediction with knowledge graphs

An interesting observation is that when we restrict relational hypergraphs to have hyperedges of arity exactly $2$, we recover the class of knowledge graphs.
C-MPNNs [] are tailored for knowledge graphs and their expressive power has been recently studied extensively, with a focus on their capability for distinguishing *pairs of nodes* (for a formal definition see Appendix A). In this section, we compare HC-MPNNs and C-MPNNs, and hence we are interested in the expressive power of HC-MPNNs in terms of distinguishing pairs of nodes. Note however that, in principle, HC-MPNNs do not compute binary invariants. Indeed, for $q\in R$ and a pair of nodes $u,v$ we can obtain two final features depending on whether we pose the query $q(u,?)$ or $q(?,v)$. As a convention, we shall define the final feature of the pair $u,v$ as the result of the query $q(u,?)$. When a HC-MPNN computes binary invariants under this convention, we say the HC-MPNN is *restricted to tail predictions*.

We proceed to show that HC-MPNNs restricted to tail predictions have the same expressive power in terms of distinguishing pairs of nodes as the
${\sf rawl}_{2}^{+}$ test proposed in Huang et al. []. This test is an extension of ${\sf rawl}_{2}$, which in turn, matches the expressive power of C-MPNNs. It follows then that HC-MPNNs are strictly more powerful than C-MPNNs over knowledge graphs.
We show this by first defining a variant of the relational WL test which upper bound the expressive power of HC-MPNNs restricting to tail predictions.

Given a knowledge graph $G=(V,E,R,c,\eta)$, where $\eta:V\times V\mapsto D$ is a pairwise coloring satisfying *target node distinguishability*, i.e. $\forall u\neq v,\eta(u,u)\neq\eta(u,v)$, we define a *relational hypergraph conditioned local 2-WL test*, denoted as ${\sf hcwl}_{2}$. ${\sf hcwl}_{2}$ iteratively updates binary coloring $\eta$ as follow for all $\ell\geq 0$:

$$ $\displaystyle{\sf hcwl}_{2}^{(0)}$ $\displaystyle=\eta(u,v)$ $\displaystyle{\sf hcwl}_{2}^{(\ell+1)}(u,v)$ $\displaystyle=\tau\Big{(}{\sf hcwl}_{2}^{(\ell)}(u,v),\{\!\!\{\big{(}\{({\sf hcwl }_{2}^{(\ell)}(u,w),j)\!\mid\!(w,j)\!\in\!{\mathcal{N}}_{i}(e)\},\rho(e)\big{) }\mid(e,i)\in E(v)\}\!\!\}\Big{)}$ $$

Note that indeed, ${\sf hcwl}_{2}^{(\ell)}$ computes a binary invariants for all $\ell\geq 0$. First, we show that HC-MPNN restricted on only tails prediction is indeed characterized by ${\sf hcwl}_{2}$. The proof idea is very similar to Theorem 5.1 in Huang et al. [].

###### Theorem H.1 .

Let $G=(V,E,R,{\bm{x}},\eta)$ be a knowledge graph where ${\bm{x}}$ is a feature map and $\eta$ is
a pairwise node coloring satisfying *target node distinguishability*. Given a query with ${\bm{q}}=(q,\tilde{{\bm{u}}},2)$, then we have:

- 1.
For all HC-MPNNs restricted on tails prediction with $L$ layers and initializations Init with $\textsc{Init}\equiv\eta$, and $0\leq\ell\leq L$ , we have
${\sf hcwl}_{2}^{(\ell)}\preceq{\bm{h}}_{\bm{q}}^{(\ell)}$
- 2.
For all $L\geq 0$ , there is an HC-MPNN restricted on tails prediction with $L$ layers such that for all $0\leq\ell\leq L$ , we have ${\sf hcwl}_{2}^{(\ell)}\equiv{\bm{h}}_{\bm{q}}^{(\ell)}$.

###### Proof.

We first rewrite the HC-MPNN restricted on tails predictions in the following form. Given a query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$, we know that since $G$ is a knowledge graph, $\tilde{{\bm{u}}}$ only consists of a single node, which we denote as $u$. In addition, since we only consider the case of tail prediction, then we always have $t=2$. With this restriction, we restate the HC-MPNN restricted on tails prediction on the knowledge graph as follows:

$$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(0)}$ $\displaystyle=\textsc{Init}(v,{\bm{q}}),$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(\ell+1)}$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{v|{\bm{q}}}^{(\ell)},\textsc{Agg} \big{(}{\bm{h}}_{v|{\bm{q}}}^{(\ell)},\{\!\!\{\textsc{Msg}_{\rho(e)}(\{({\bm{h }}_{w|{\bm{q}}}^{(\ell)},j)\mid(w,j)\in{\mathcal{N}}_{i}(e)\}),\mid(e,i)\in E( v)\}\!\!\}\big{)}\Big{)}$ $$

Now, we follow a similar idea in the proof of C-MPNN for binary invariants []. Let $G=(V,E,R,c,\eta)$ be a knowledge graph where $\eta$ is a pairwise coloring. Construct the auxiliary knowledge graph $G^{2}=(V\times V,E^{\prime},R,c_{\eta})$ where $E^{\prime}=\{r((u,w),(u,v))\mid r(w,v)\in E,r\in R\}$ and $c_{\eta}$ is the node coloring $c_{\eta}((u,v))=\eta(u,v)$. Similar to Theorem 5.1,
If ${\mathcal{A}}$ is a HC-MPNN and ${\mathcal{B}}$ is an HR-MPNN, we write ${\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(u,v):={\bm{h}}_{(q,(u),2)}^{(\ell)}(v)$ and ${\bm{h}}_{{\mathcal{B}},G^{2}}^{(\ell)}((u,v)):={\bm{h}}^{(\ell)}((u,v))$ for the features computed by ${\mathcal{A}}$ and ${\mathcal{B}}$ over $G$ and $G^{2}$, respectively. We sometimes write ${\mathcal{N}}^{G}_{r}(e)$ and $E^{G}(v)$ to emphasize that the positional neighborhood within a hyperedge and set of hyperedges including node $v$ is taken over the knowledge graph $G$, respectively.
Finally, we say that an initial feature map ${\bm{y}}$ for $G^{2}$ satisfies
generalized target node distinguishability if ${\bm{y}}((u,u))\neq{\bm{y}}((u,v))$ for all $u\neq v$. Note here that the generalized target node distinguishability naturally reduced to *target node distinguishability* proposed in Huang et al. [] since $\tilde{{\bm{u}}}$ is a singleton.
Thus, we have the following equivalence between HR-MPNN and HC-MPNN restricted on tail prediction on the knowledge graph.

###### Proposition H.2 .

Let $G=(V,E,R,{\bm{x}},\eta)$ be a knowledge graph where ${\bm{x}}$ is a feature map, and $\eta$ is a pairwise coloring. Let $q\in R$, then:

- 1.
For every HC-MPNN ${\mathcal{A}}$ with $L$ layers, there is an initial feature map ${\bm{y}}$ for $G^{2}$ an HR-MPNN ${\mathcal{B}}$ with $L$ layers such that for all $0\leq\ell\leq L$ and $u,v\in V$, we have ${\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(u,v)={\bm{h}}_{{\mathcal{B}},G^{2}}^{(\ell
)}((u,v))$.
- 2.
For every initial feature map ${\bm{y}}$ for $G^{2}$ satisfying generalized target node distinguishability and every HR-MPNN ${\mathcal{B}}$ with $L$ layers, there is a HC-MPNN ${\mathcal{A}}$ with $L$ layers such that for all $0\leq\ell\leq L$ and $u,v\in V$, we have ${\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(u,v)={\bm{h}}_{{\mathcal{B}},G^{2}}^{(\ell
)}((u,v))$.

###### Proof.

We proceed to show item (1) first. Consider the HR-MPNN $\mathcal{B}$ with the same relational-specific message $\textsc{Msg}_{r}$, aggregation Agg, and update functions Up as $\mathcal{A}$ for all the $L$ layers. The initial feature map ${\bm{y}}$ is defined as ${\bm{y}}((u,v))=\textsc{Init}(v,(q,(u),2))$, where Init is the initialization function of $\mathcal{A}$. Then, by induction on number of layer $\ell$, we have that for the base case $\ell=0$, ${\bm{h}}_{{\mathcal{A}}}^{(0)}(u,v)=\textsc{Init}(v,(q,(u),2))={\bm{y}}((u,v))
={\bm{h}}_{{\mathcal{B}}}^{(0)}((u,v))$. For the inductive case, assume ${\bm{h}}_{{\mathcal{A}}}^{(\ell)}(u,v)={\bm{h}}_{{\mathcal{B}}}^{(\ell)}((u,v))$, then

$$ $\displaystyle{\bm{h}}_{{\mathcal{A}}}^{(\ell+1)}(u,v)$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{{\mathcal{A}}}^{(\ell)}(u,v),\textsc {Agg}\big{(}{\bm{h}}_{{\mathcal{A}}}^{(\ell)}(u,v),$ $\displaystyle\qquad\qquad\{\!\!\{\textsc{Msg}_{\rho(e)}\Big{(}\{({\bm{h}}_{{ \mathcal{A}}}^{(\ell)}(u,w),j)\mid(w,j)\in{\mathcal{N}}_{i}^{G}(e)\}\Big{)} \mid(e,i)\in E^{G}(v)\}\!\!\}\big{)}\Big{)}$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{{\mathcal{B}}}^{(\ell)}((u,v)), \textsc{Agg}\big{(}{\bm{h}}_{{\mathcal{B}}}^{(\ell)}((u,v)),$ $\displaystyle\qquad\qquad\{\!\!\{\textsc{Msg}_{\rho(e)}\Big{(}\{({\bm{h}}_{{ \mathcal{B}}}^{(\ell)}((u,w)),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i}^{G^{2}}(e)\} \Big{)}\!\mid\!(e,i)\in E^{G^{2}}(v)\}\!\!\}\big{)}\Big{)}$ $\displaystyle={\bm{h}}_{{\mathcal{B}}}^{(\ell+1)}((u,v)).$ $$

To show item (2), we consider ${\mathcal{A}}$ with the same relational-specific message $\textsc{Msg}_{r}$, aggregation Agg, and update functions Up as $\mathcal{B}$ for all the $L$ layers. We also take initialization function Init such that $\textsc{Init}(v,(q,(u),2))={\bm{y}}((u,v))$. Then, we can follow the same argument for the equivalence as item (1).
∎

We then show the equivalence in terms of the relational WL algorithms:

###### Proposition H.3 .

Let $G=(V,E,R,c,\eta)$ be a knowledge graph where $\eta$ is a pairwise coloring. For all $\ell\geq 0$ and $u,v\in V$, we have that ${\sf hcwl}_{2}^{(\ell)}(u,v)$ computed over $G$ coincides with
${\sf hrwl}_{1}^{(\ell)}((u,v))$ computed over $G^{2}=(V\times V,E^{\prime},R,c_{\eta})$.

###### Proof.

For $\ell=0$, we have ${\sf hcwl}_{2}^{(0)}(G,u,v)=\eta(u,v)=c_{\eta}((u,v))={\sf hrwl}_{1}^{(0)}(G^{
2},(u,v))$. For the inductive case, we have that

$$ $\displaystyle{\sf hcwl}_{2}^{(\ell+1)}(G,u,v)$ $\displaystyle=\tau\Big{(}{\sf hcwl}_{2}^{(\ell)}(G,u,v),$ $\displaystyle\qquad\{\!\!\{\big{(}\{({\sf hcwl}_{2}^{(\ell)}(G,u,w),j)\mid(w,j )\in{\mathcal{N}}^{G}_{i}(e)\},\rho(e)\big{)}\mid(e,i)\in E^{G}(v)\}\!\!\}\Big {)}$ $\displaystyle=\tau\Big{(}{\sf hrwl}_{1}^{(\ell)}(G^{2},(u,v)),$ $\displaystyle\qquad\{\!\!\{\big{(}\{({\sf hrwl}_{1}^{(\ell)}(G^{2},(u,w)),j) \mid(w,j)\in{\mathcal{N}}^{G^{2}}_{i}(e)\},\rho(e)\big{)}\mid(e,i)\in E^{G^{2} }(v)\}\!\!\}\Big{)}$ $\displaystyle={\sf hrwl}_{1}^{(\ell+1)}(G^{2},(u,v)).$ $$

∎

Now we are ready to show the proof for Theorem H.1. For $G=(V,E,R,{\bm{x}},\eta)$, we consider $G^{2}=(V\times V,E^{\prime},R,c_{\eta})$.
We start with item (1).
Let ${\mathcal{A}}$ be a HC-MPNN with $L$ layers and initialization Init satisfying $\textsc{Init}\equiv\eta$ and let $0\leq\ell\leq L$. Let ${\bm{y}}$ be an initial feature map for $G^{2}$ and ${\mathcal{B}}$ be an HR-MPNN with $L$ layers in Proposition H.2, item (1). For the initialization we have ${\bm{y}}\equiv c_{\eta}$ since ${\bm{y}}((u,v))=\textsc{Init}(v,(q,(u),2))$. Thus, we can proceed and apply Theorem 4.1, item (1) to $G^{2}$, ${\bm{y}}$, and ${\mathcal{B}}$ and show that ${\sf hrwl}_{1}^{(\ell)}\preceq{\bm{h}}_{{\mathcal{B}},G^{2}}^{(\ell)}$, which in turns shows that ${\sf hcwl}_{2}^{(\ell)}\preceq{\bm{h}}_{{\mathcal{A}},G}^{(\ell)}$.

We then proceed to show item (2). Let $L\geq 0$ be an integer representing a total number of layers. We apply Theorem 4.1, item (2) to $G^{2}$ and obtain an initial feature map ${\bm{y}}$ with ${\bm{y}}\equiv c_{\eta}$ and an HR-MPNN ${\mathcal{B}}$ with $L$ layer such that ${\sf hrwl}_{1}^{(\ell)}\equiv{\bm{h}}_{{\mathcal{B}},G^{2}}^{(\ell)}$ for all $0\leq\ell\leq L$. We stress again that ${\bm{y}}$ and $\eta$ both satisfied generalized target node distinguishability. Now, let ${\mathcal{A}}$ be the HC-MPNN from Proposition H.2, item (2). We finally have that ${\sf hcwl}_{2}^{(\ell)}\equiv{\bm{h}}_{{\mathcal{A}},G}^{(\ell)}$ as required. Note that the item (2) again holds for HCNet.

∎

We are ready to prove the claim that HC-MPNN is more powerful than C-MPNN by showing the strict containment of their corresponding relational WL test, that is, ${\sf hcwl}_{2}$ and ${\sf rawl}_{2}$. In particular, we show that the defined ${\sf hcwl}_{2}$ is equivalent to ${\sf rawl}_{2}^{+}$ defined in Huang et al. [], via Theorem H.4. Then, by Proposition A.17 in Huang et al. [], we have that ${\sf rawl}_{2}^{+}\prec{\sf rawl}_{2}$.

The intuition of Theorem H.4 is that for each updating step, ${\sf hcwl}_{2}$ aggregates over all the neighboring edges, which contain both incoming edges and outgoing edges. In addition, ${\sf hcwl}_{2}$ can differentiate between them via the position of the entities in the edge. This is equivalent to aggregating incoming relation and outgoing inversed-relation in ${\sf rawl}_{2}^{+}$.

###### Theorem H.4 .

For all knowledge graph $G=(V,E,R,c)$, let ${\sf hcwl}_{2}^{(0)}(G)\equiv{{\sf rawl}_{2}^{+}}^{(0)}(G)$, then ${\sf hcwl}_{2}^{(\ell)}(G)\equiv{{\sf rawl}_{2}^{+}}^{(\ell)}(G)$ for all $\ell\geq 0$.

###### Proof.

First we restate the definition of ${\sf hcwl}_{2}(G)$ and ${\sf rawl}^{+}_{2}(G)$ for convenience. Given that the query is always a tail query, i.e., $k=2$, and given a knowledge graph $G=(V,E,R,c)$, we have that the updating formula for ${\sf hcwl}_{2}(G)$ is

$$ $\displaystyle{\sf hcwl}_{2}^{(\ell+1)}(G,(u,v))$ $\displaystyle=\tau({\sf hcwl}_{2}^{(\ell)}(G,(u,v)),$ $\displaystyle\qquad\{\!\!\{(\{({\sf hcwl}_{2}^{(\ell)}(G,(u,w)),j)\mid(w,j)\in {\mathcal{N}}_{i}(e)\},\rho(e))\mid(e,i)\in E(v)\}\!\!\})$ $\displaystyle=\tau({\sf hcwl}_{2}^{(\ell)}(G,(u,v)),$ $\displaystyle\qquad\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w, j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v)\}\!\!\})$ $$

Note here that the second equation comes from the fact that the maximum arity is always $2$.
Then, recall the definition of ${\sf rawl}_{2}$. Given a knowledge graph $G=(V,E,R,c,\eta)$, where $\eta$ is a pairwise coloring only, we have

$$ $\displaystyle{\sf rawl}_{2}^{(\ell+1)}(G,(u,v))={\tau}\big{(}{\sf rawl}_{2}^{( \ell)}(G,(u,v)),\{\!\!\{({\sf rawl}_{2}^{(\ell)}(G,(u,w)),r)\mid w\in{\mathcal {N}}_{r}(v),r\in R)\}\!\!\}\big{)}$ $$

where ${\mathcal{N}}_{r}(v)$ is the relational neighborhood with respect to relation $r\in R$, i.e., $w\in{\mathcal{N}}_{r}(v)$ if and only if $r(v,w)\in E$.
Equivalently, we can rewrite ${\sf rawl}_{2}$ in the following form:

$$ $\displaystyle{\sf rawl}_{2}^{(\ell+1)}(G,(u,v))$ $\displaystyle={\tau}\big{(}{\sf rawl}_{2}^{(\ell)}(G,(u,v)),$ $\displaystyle\qquad\{\!\!\{({\sf rawl}_{2}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}\big{)}$ $$

since we only want to obtain the node $w$ as the tails entities in an edge, and thus the second argument of the (only) element in ${\mathcal{N}}_{i}(e)$ will always be $2$.

For a test ${\sf T}$, we sometimes write ${\sf T}(G,{\bm{u}})$, or ${\sf T}(G,u,v)$ in case of binary tests, to emphasize that the test is applied over $G$, and ${\sf T}(G)$ for the pairwise/$k$-ary coloring given by the test.
Let $G=(V,E,R,c,\eta)$ be a knowledge graph. The, note that $G^{+}=(V,E^{+},R^{+})$ is the *augmented knowledge graph* where $R^{+}$ is the disjoint union of $R$ and $\{r^{-}\mid r\in R\}$, and

$$ $E^{-}=\{r^{-}(v,u)\mid r(u,v)\in E,u\neq v\}$ $$

$$ $E^{+}=E\cup E^{-}$ $$

We can then define

$$ $\displaystyle E{(v)}$ $\displaystyle=\left\{(e,i)\mid e(i)=v,e\in E\right\}$ $\displaystyle E^{+}{(v)}$ $\displaystyle=\left\{(e,i)\mid e(i)=v,e\in E^{+}\right\}$ $\displaystyle E^{-}{(v)}$ $\displaystyle=\left\{(e,i)\mid e(i)=v,e\in E^{-}\right\}.$ $$

Finally, recall the definition of ${\sf rawl}^{+}_{2}(G,u,v)={\sf rawl}_{2}(G^{+},u,v)$. We can write this in the equivalent form:

$$ $\displaystyle{{\sf rawl}_{2}^{+}}^{(\ell+1)}(G,(u,v))$ $\displaystyle={\tau}\big{(}{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,v)),$ $\displaystyle\qquad\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e)) \mid(w,j)\in{\mathcal{N}}_{i}(e),(e,i)\in E^{+}(v),i=1\}\!\!\}\big{)}$ $\displaystyle={\tau}\big{(}{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,v)),$ $\displaystyle\qquad\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e)) \mid(w,j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}$ $\displaystyle\qquad\cup\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e) )\mid(w,j)\in{\mathcal{N}}_{i}(e),(e,i)\in E^{-}(v),i=1\}\!\!\}\big{)}$ $$

Now we are ready to show the proof. First we show that ${\sf hcwl}_{2}^{(\ell)}(G)\equiv{{\sf rawl}_{2}^{+}}^{(\ell)}(G)$.
We prove by induction the number of layers $\ell$ by showing that for some $u,v\in V$ and for some $\ell$,

$$ ${\sf hcwl}_{2}^{(\ell+1)}(G,(u,v))={\sf hcwl}_{2}^{(\ell+1)}(G,(u^{\prime},v^{ \prime}))\equiv{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,v))={{\sf rawl}_{2}^{+}}^{( \ell)}(G,(u^{\prime},v^{\prime}))$ $$

By assumption, we know the base case holds. Assume that ${\sf hcwl}_{2}^{(\ell)}(G)\equiv{{\sf rawl}_{2}^{+}}^{(\ell)}(G)$ for some $\ell\geq 0$, for a pair of node-pair $(u,v),(u^{\prime},v^{\prime})\in V^{2}$, Given that

$$ $\displaystyle{\sf hcwl}_{2}^{(\ell+1)}(G,(u,v))$ $\displaystyle={\sf hcwl}_{2}^{(\ell+1)}(G,(u^{\prime},v^{\prime}))$ $$

By definition, we have that

$$ $\displaystyle\tau({\sf hcwl}_{2}^{(\ell)}(G,(u,v)),\{\!\!\{({\sf hcwl}_{2}^{( \ell)}(G,(u,w)),j,\rho(e))\mid(w,j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v)\}\!\! \})=$ $\displaystyle\tau({\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},v^{\prime})),\{\!\!\{( {\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e^{\prime}))\mid(w,j)\in{ \mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{\prime})\}\!\!\})$ $$

Conditioning on $i\in\{1,2\}$, we can further decompose the set.

$$ $\displaystyle\tau({\sf hcwl}_{2}^{(\ell)}(G,(u,v)),$ $\displaystyle\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w,j)\in{ \mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\},$ $\displaystyle\cup\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=2\}\!\!\})=$ $\displaystyle\tau({\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},v^{\prime})),$ $\displaystyle\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\},$ $\displaystyle\cup\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=2\}\!\!\})$ $$

Assume $\tau$ is injective, the three arguments in $\tau$ must match, i.e., ${\sf hcwl}_{2}^{(\ell)}(G,(u,v))={\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},v^{
\prime}))$, and

$$ $\displaystyle\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w,j)\in{ \mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}=$ $\displaystyle\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\}$ $$

We also have

$$ $\displaystyle\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w,j)\in{ \mathcal{N}}_{i}(e),(e,i)\in E(v),i=2\}\!\!\}=$ $\displaystyle\{\!\!\{({\sf hcwl}_{2}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=2\}\!\!\}$ $$

By inductive hypothesis, we have that ${{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,v))={{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{
\prime},v^{\prime})).$
Thus, we have that

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w, j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e ^{\prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\}$ $$

and also

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w, j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=2\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e ^{\prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=2\}\!\!\}$ $$

First, for the first equation, we notice that

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w, j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e ^{\prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\}$ $$

if and only if

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\}$ $$

since the filtered set of pair $(w,j)$ are the same, and the $({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))$ and $({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{\prime}))$ matches if and only if $({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),2,\rho(e))$ and $({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),2,\rho(e^{\prime}))$ matches. This is because we simply augment an additional position indicator $2$ in the tuple as we fixed $i=1$, which does not break the equivalence of the statements.

Then, for the second equation, we note that

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),j,\rho(e))\mid(w, j)\in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=2\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),j,\rho(e ^{\prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=2\}\!\!\}$ $$

if and only if

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E^{-}(v),i=1\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E^{-}(v^{ \prime}),i=1\}\!\!\}$ $$

since this time the filtered set of pair $(w,j)$ also matches, but for the inverse relation. For any edge $e\in E(v)$ where $(w,1)\in{\mathcal{N}}_{e}(v)$, the edge will be in form $\rho(e)(w,v)$ as $w$ is placed in the first position. Thus, there will be a corresponding reversed edge $\rho(e)^{-1}(v,w)\in E^{-}$ by definition. Then, by the same argument as in the second equation above, adding such an additional position indicator $1$ on every tuple will not break the equivalence of the statement.

An important observation is that since the inverse relations are freshly created, we will never mix up these inverse edges in both tests. For ${{\sf rawl}_{2}^{+}}$, we can distinguish these edges by checking the freshly created relation symbols $r^{-1}\in R^{+}\backslash R$, whereas in ${\sf hcwl}_{2}$, the neighboring nodes from these edges are identified with the position indicator $1$ in the tuple.

Thus, we have that

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\}$ $$

and also

$$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E^{-}(v),i=1\}\!\!\}\big{)}=$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E^{-}(v^{ \prime}),i=1\}\!\!\}\big{)}$ $$

Since $\tau$ is injective, this is equivalent to

$$ $\displaystyle{\tau}\big{(}{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,v)),$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E(v),i=1\}\!\!\}$ $\displaystyle\cup\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid( w,j)\in{\mathcal{N}}_{i}(e),(e,i)\in E^{-}(v),i=1\}\!\!\}\big{)}=$ $\displaystyle{\tau}\big{(}{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},v^{ \prime})),$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E(v^{ \prime}),i=1\}\!\!\}$ $\displaystyle\cup\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho (e^{\prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E^{-} (v^{\prime}),i=1\}\!\!\}\big{)}$ $$

and thus, we have

$$ $\displaystyle{\tau}\big{(}{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,v)),$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u,w)),\rho(e))\mid(w,j) \in{\mathcal{N}}_{i}(e),(e,i)\in E^{+}(v),i=1\}\!\!\}\big{)}=$ $\displaystyle{\tau}\big{(}{{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},v^{ \prime})),$ $\displaystyle\{\!\!\{({{\sf rawl}_{2}^{+}}^{(\ell)}(G,(u^{\prime},w)),\rho(e^{ \prime}))\mid(w,j)\in{\mathcal{N}}_{i}(e^{\prime}),(e^{\prime},i)\in E^{+}(v^{ \prime}),i=1\}\!\!\}\big{)}$ $$

and finally

$$ ${{\sf rawl}_{2}^{+}}^{(\ell+1)}(G,(u,v))={{\sf rawl}_{2}^{+}}^{(\ell+1)}(G,(u^ {\prime},v^{\prime}))$ $$

Note that since all arguments apply for both directions, the converse holds.
∎

###### Remark H.5 .

We remark that the idea of HC-MPNNs restricted to tail predictions can be extended to arbitrary relational hypergraphs in order to compute $k$-ary invariants for any $k$. See Appendix I for a discussion.

###### Theorem H.1 .

###### Proof.

###### Proposition H.2 .

###### Proof.

###### Proposition H.3 .

###### Proof.

###### Theorem H.4 .

###### Proof.

###### Remark H.5 .

## Appendix I Computing k 𝑘 k italic_k -ary invariants

In this section, we present a canonical way to construct a valid $k$-ary invariants. We start by introducing a construction of a valid $k$-ary invariants termed as *atomic types*, following the convention by Grohe [].

### I.1 Atomic types

Given a relational hypergraph $G=(V,E,R,c)$ with $l$ labels and a tuple ${\bm{u}}=(u_{1},...,u_{k})\in V^{k}$, where $k>1$, we define the *atomic type* of ${\bm{u}}$ in $G$ as a vector:

$$ $\mathtt{atp}_{k}(G)({\bm{u}})\in\{0,1\}^{lk+{k\choose 2}+m^{2}+|R|k^{m}},$ $$

where $l$ is the number of colors and $m$ is the arity of the relation with maximum arity. We use the first $lk$ bits to represent the color of the $k$ nodes in ${\bm{u}}$, another ${k\choose 2}$ bits to indicate whether node $u_{i}$ is identical to $u_{j}$. We then represent the order of these nodes using $m^{2}$ bits and finally represent the relation with additional $|R|k^{m}$ bits.

Atomic types are *$k$-ary relational hypergraph invariants* as they satisfy the property that $\mathtt{atp}_{k}(G)({\bm{u}})=\mathtt{atp}_{k}(G^{\prime})({\bm{u}}^{\prime})$ if and only if the mapping $u_{1}\mapsto u^{\prime}_{1}$, $\ldots$, $u_{k}\mapsto u^{\prime}_{k}$ is an isomorphism from the induced subgraph $G[\{u_{1},\cdots,u_{k}\}]$ to $G^{\prime}[\{u^{\prime}_{1},\cdots,u^{\prime}_{k}\}]$.

### I.2 Relational hypergraph conditioned
local k 𝑘 k italic_k -WL test

Now we are ready to show the $k$-ary invariants. Similarly to ${\sf hcwl}_{2}$, we can restrict HC-MPNN to only carry out a tail prediction with relational hypergraphs to make sure it directly computes $k$-ary invariants. Here, we introduce *Relational hypergraph conditioned local $k$-WL test*, dubbed ${\sf hcwl}_{k}$, which naturally generalized ${\sf hcwl}_{2}$ to relational hypergraph. Given $\tilde{{\bm{u}}}\in V^{k-1}$ and a relational hypergraph $G=(V,E,R,c,\zeta)$ where $\zeta:V^{k}\mapsto D$ is a $k$-ary coloring that satisfied generalized target node distinguishability, i.e.,

$$ $\displaystyle\zeta(\tilde{{\bm{u}}},u)$ $\displaystyle\neq\zeta(\tilde{{\bm{u}}},v)\quad\forall u\in\tilde{{\bm{u}}},v \notin\tilde{{\bm{u}}},$ $\displaystyle\zeta(\tilde{{\bm{u}}},u_{i})$ $\displaystyle\neq\zeta(\tilde{{\bm{u}}},u_{j})\quad\forall u_{i},u_{j}\in \tilde{{\bm{u}}},u_{i}\neq u_{j}.$ $$

${\sf hcwl}_{k}$ updates $k$-ary coloring $\zeta$ for $\ell\geq 0$:

$$ $\displaystyle{\sf hcwl}_{k}^{(0)}$ $\displaystyle=\zeta(\tilde{{\bm{u}}},v)$ $\displaystyle{\sf hcwl}_{k}^{(\ell+1)}(\tilde{{\bm{u}}},v)$ $\displaystyle=\tau\Big{(}{\sf hcwl}_{k}^{(\ell)}(\tilde{{\bm{u}}},v),\{\!\!\{ \big{(}\{({\sf hcwl}_{k}^{(\ell)}(\tilde{{\bm{u}}},w),j)\!\mid\!(w,j)\in{ \mathcal{N}}_{i}(e)\},\rho(e)\big{)}\!\mid\!(e,i)\!\in\!E(v)\}\!\!\}\Big{)}$ $$

Again, we notice that ${\sf hcwl}_{k}^{(\ell)}$ computes a valid $k$-ary invariants. We can also show that HC-MPNN restricted on tails prediction, i.e., for each query ${\bm{q}}=(q,\tilde{{\bm{u}}},j)$ where $j=k$, is characterized by ${\sf hcwl}_{k}$.

###### Theorem I.1 .

Let $G=(V,E,R,{\bm{x}},\zeta)$ be a relational hypergraphs where ${\bm{x}}$ is a feature map and $\zeta$ is
a $k$-ary node coloring satisfying *generalized target nodes distinguishability*. Given a query with ${\bm{q}}=(q,\tilde{{\bm{u}}},k)$, then we have that:

- 1.
For all HC-MPNNs restricted on tails prediction with $L$ layers and initializations Init with $\textsc{Init}\equiv\eta$, and $0\leq\ell\leq L$ , we have
${\sf hcwl}_{k}^{(\ell)}\preceq{\bm{h}}_{\bm{q}}^{(\ell)}$
- 2.
For all $L\geq 0$ , there is an HC-MPNN restricted on tails prediction with $L$ layers such that for all $0\leq\ell\leq L$ , we have ${\sf hcwl}_{k}^{(\ell)}\equiv{\bm{h}}_{\bm{q}}^{(\ell)}$.

###### Proof.

The proof is very similar to that in Theorem H.1. Note that we sometimes write a $k$-ary tuple ${\bm{v}}=(u_{1},\cdots,u_{k})\in V^{k}$ by $({\bm{u}},u_{k})$ where ${\bm{u}}=(u_{1},\cdots,u_{k-1})$ with a slight abuse of notation. We build an auxiliary relational hypergraph $G^{k}=(V^{k},E^{\prime},R,c_{\zeta})$ where $E^{\prime}=\{r((\tilde{{\bm{u}}},v_{1}),\cdots,(\tilde{{\bm{u}}},v_{m}))\mid r
(v_{1},\cdots,v_{m})\in E,r\in R\}$, and $c_{\zeta}$ is a node coloring $c_{\zeta}((\tilde{{\bm{u}}},v))=\zeta(\tilde{{\bm{u}}},v)$. If ${\mathcal{A}}$ is a HC-MPNN and ${\mathcal{B}}$ is an HR-MPNN, we write ${\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(\tilde{{\bm{u}}},v):={\bm{h}}_{{\bm{q}}}^{
(\ell)}(v)$ and ${\bm{h}}_{{\mathcal{B}},G^{k}}^{(\ell)}((\tilde{{\bm{u}}},v)):={\bm{h}}^{(\ell
)}((\tilde{{\bm{u}}},v))$ for the features computed by ${\mathcal{A}}$ and ${\mathcal{B}}$ over $G$ and $G^{k}$, respectively.
Again, we write ${\mathcal{N}}^{G}_{r}(e)$ and $E(v)^{G}$ to emphasize that the positional neighborhood, as well as the hyperedges containing node $v$, is taken over the relational hypergraph $G$, respectively.
Finally, we say that an initial feature map ${\bm{y}}$ for $G^{k}$ satisfies
generalized target node distinguishability if

$$ $\displaystyle{\bm{y}}((\tilde{{\bm{u}}},u))$ $\displaystyle\neq{\bm{y}}((\tilde{{\bm{u}}},v))\quad\forall u\in\tilde{{\bm{u} }},v\notin\tilde{{\bm{u}}},$ $\displaystyle{\bm{y}}((\tilde{{\bm{u}}},u_{i}))$ $\displaystyle\neq{\bm{y}}((\tilde{{\bm{u}}},u_{j}))\quad\forall u_{i},u_{j}\in \tilde{{\bm{u}}},u_{i}\neq u_{j}.$ $$

As a result, we have the following equivalence between HR-MPNN and HC-MPNN restricted on tail prediction with the relational hypergraph.

###### Proposition I.2 .

Let $G=(V,E,R,{\bm{x}},\zeta)$ be a knowledge graph where ${\bm{x}}$ is a feature map, and $\zeta$ is a $k$-ary nodes coloring. Let $q\in R$, then:

- 1.
For every HC-MPNN ${\mathcal{A}}$ with $L$ layers, there is an initial feature map ${\bm{y}}$ for $G^{k}$ an HR-MPNN ${\mathcal{B}}$ with $L$ layers such that for all $0\leq\ell\leq L$ and $u,v\in V$, we have ${\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(\tilde{{\bm{u}}},v)={\bm{h}}_{{\mathcal{B}
},G^{2}}^{(\ell)}((\tilde{{\bm{u}}},v))$.
- 2.
For every initial feature map ${\bm{y}}$ for $G^{k}$ satisfying generalized target node distinguishability and every HR-MPNN ${\mathcal{B}}$ with $L$ layers, there is a HC-MPNN ${\mathcal{A}}$ with $L$ layers such that for all $0\leq\ell\leq L$ and $(\tilde{vu},v)\in V^{k}$, we have ${\bm{h}}_{{\mathcal{A}},G}^{(\ell)}(\tilde{{\bm{u}}},v)={\bm{h}}_{{\mathcal{B}
},G^{k}}^{(\ell)}((\tilde{{\bm{u}}},v))$.

###### Proof.

We first show item (1). Consider the HR-MPNN $\mathcal{B}$ with the same relational-specific message $\textsc{Msg}_{r}$, aggregation Agg, and update functions Up as $\mathcal{A}$ for all the $L$ layers. The initial feature map ${\bm{y}}$ is defined as ${\bm{y}}((\tilde{{\bm{u}}},v))=\textsc{Init}(v,{\bm{q}})$, where Init is the initialization function of $\mathcal{A}$. Then, by induction on number of layer $\ell$, we have that for the base case $\ell=0$, ${\bm{h}}_{{\mathcal{A}}}^{(0)}(\tilde{{\bm{u}}},v)=\textsc{Init}(v,{\bm{q}})={
\bm{y}}((\tilde{{\bm{u}}},v))={\bm{h}}_{{\mathcal{B}}}^{(0)}((\tilde{{\bm{u}}}
,v))$.

For the inductive case, assume ${\bm{h}}_{{\mathcal{A}}}^{(\ell)}(\tilde{{\bm{u}}},v)={\bm{h}}_{{\mathcal{B}}}
^{(\ell)}((\tilde{{\bm{u}}},v))$, then

$$ $\displaystyle{\bm{h}}_{{\mathcal{A}}}^{(\ell+1)}(\tilde{{\bm{u}}},v)$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{{\mathcal{A}}}^{(\ell)}(\tilde{{\bm{ u}}},v),\textsc{Agg}\big{(}{\bm{h}}_{{\mathcal{A}}}^{(\ell)}(\tilde{{\bm{u}}}, v),$ $\displaystyle\qquad\{\!\!\{\textsc{Msg}_{\rho(e)}\Big{(}\{({\bm{h}}_{{\mathcal {A}}}^{(\ell)}(\tilde{{\bm{u}}},w),j)\mid(w,j)\in{\mathcal{N}}_{i}^{G}(e)\} \Big{)}\mid(e,i)\in E^{G}(v)\}\!\!\}\big{)}\Big{)}$ $\displaystyle=\textsc{Up}\Big{(}{\bm{h}}_{{\mathcal{B}}}^{(\ell)}((\tilde{{\bm {u}}},v)),\textsc{Agg}\big{(}{\bm{h}}_{{\mathcal{B}}}^{(\ell)}((\tilde{{\bm{u} }},v)),$ $\displaystyle\qquad\{\!\!\{\textsc{Msg}_{\rho(e)}\Big{(}\{({\bm{h}}_{{\mathcal {B}}}^{(\ell)}((\tilde{{\bm{u}}},w)),j)\!\mid\!(w,j)\in{\mathcal{N}}_{i}^{G^{k }}(e)\}\Big{)}\!\mid\!(e,i)\in E^{G^{k}}(v)\}\!\!\}\big{)}\Big{)}$ $\displaystyle={\bm{h}}_{{\mathcal{B}}}^{(\ell+1)}((\tilde{{\bm{u}}},v)).$ $$

To show item (2), we consider ${\mathcal{A}}$ with the same relational-specific message $\textsc{Msg}_{r}$, aggregation Agg, and update functions Up as $\mathcal{B}$ for all the $L$ layers. We also take initialization function Init such that $\textsc{Init}(v,{\bm{q}})={\bm{y}}((\tilde{{\bm{u}}},v))$. Then, we can follow the same argument for the equivalence as item (1).
∎

Similarly, we can show the equivalence in terms of the relational WL algorithms with ${\sf hcwl}_{k}$:

###### Proposition I.3 .

Let $G=(V,E,R,c,\zeta)$ be a relational hypergraph where $\zeta$ is a $k$-ary node coloring. For all $\ell\geq 0$ and $(\tilde{{\bm{u}}},v)\in V^{k}$, we have that ${\sf hcwl}_{k}^{(\ell)}(\tilde{{\bm{u}}},v)$ computed over $G$ coincides with
${\sf hrwl}_{1}^{(\ell)}((\tilde{{\bm{u}}},v))$ computed over $G^{k}=(V^{k},E^{\prime},R,c_{\zeta})$.

###### Proof.

For $\ell=0$, we have ${\sf hcwl}_{k}^{(0)}(G,\tilde{{\bm{u}}},v)=\zeta(\tilde{{\bm{u}}},v)=c_{\zeta}
((\tilde{{\bm{u}}},v))={\sf hrwl}_{1}^{(0)}(G^{k},(\tilde{{\bm{u}}},v))$.

For the inductive case, we have that

$$ $\displaystyle{\sf hcwl}_{k}^{(\ell+1)}(G,\tilde{{\bm{u}}},v)$ $\displaystyle=\tau\Big{(}{\sf hcwl}_{k}^{(\ell)}(G,\tilde{{\bm{u}}},v),$ $\displaystyle\qquad\{\!\!\{\big{(}\{({\sf hcwl}_{2}^{(\ell)}(G,\tilde{{\bm{u}} },w),j)\mid(w,j)\in{\mathcal{N}}^{G}_{i}(e)\},\rho(e)\big{)}\mid(e,i)\in E^{G} (v)\}\!\!\}\Big{)}$ $\displaystyle=\tau\Big{(}{\sf hrwl}_{1}^{(\ell)}(G^{k},(\tilde{{\bm{u}}},v)),$ $\displaystyle\qquad\{\!\!\{\big{(}\{({\sf hrwl}_{1}^{(\ell)}(G^{k},(\tilde{{ \bm{u}}},w)),j)\!\mid\!(w,j)\in{\mathcal{N}}^{G^{k}}_{i}(e)\},\rho(e)\big{)}\! \mid\!(e,i)\in E^{G^{k}}(v)\}\!\!\}\Big{)}$ $\displaystyle={\sf hrwl}_{1}^{(\ell+1)}(G^{k},(\tilde{{\bm{u}}},v)).$ $$

∎

Now we are ready to show the proof for Theorem I.1. For a relational hypergraph $G=(V,E,R,{\bm{x}},\zeta)$, we consider $G^{k}=(V^{k},E^{\prime},R,c_{\zeta})$ as defined earlier.
We start with item (1).
Let ${\mathcal{A}}$ be a HC-MPNN with $L$ layers and initialization Init satisfying $\textsc{Init}\equiv\zeta$ and let $0\leq\ell\leq L$. Let ${\bm{y}}$ be an initial feature map for $G^{k}$ and ${\mathcal{B}}$ be an HR-MPNN with $L$ layers in Proposition I.2, item (1). For the initialization we have ${\bm{y}}\equiv c_{\zeta}$ since ${\bm{y}}((\tilde{{\bm{u}}},v))=\textsc{Init}(v,{\bm{q}})$. Thus, we can proceed and apply Theorem 4.1, item (1) to $G^{k}$, ${\bm{y}}$, and ${\mathcal{B}}$ and show that ${\sf hrwl}_{1}^{(\ell)}\preceq{\bm{h}}_{{\mathcal{B}},G^{k}}^{(\ell)}$, which in turns shows that ${\sf hcwl}_{k}^{(\ell)}\preceq{\bm{h}}_{{\mathcal{A}},G}^{(\ell)}$.

We then proceed to show item (2). Let $L\geq 0$ be an integer representing a total number of layers. We apply Theorem 4.1, item (2) to $G^{k}$ and obtain an initial feature map ${\bm{y}}$ with ${\bm{y}}\equiv c_{\zeta}$ and an HR-MPNN ${\mathcal{B}}$ with $L$ layer such that ${\sf hrwl}_{1}^{(\ell)}\equiv{\bm{h}}_{{\mathcal{B}},G^{k}}^{(\ell)}$ for all $0\leq\ell\leq L$. We stress again that ${\bm{y}}$ and $\zeta$ both satisfy generalized target node distinguishability. Now, let ${\mathcal{A}}$ be the HC-MPNN from Proposition I.2, item (2). Thus, ${\sf hcwl}_{k}^{(\ell)}\equiv{\bm{h}}_{{\mathcal{A}},G}^{(\ell)}$ as required. Again, we note that the item (2) holds for HCNet.

∎

###### Theorem I.1 .

###### Proof.

###### Proposition I.2 .

###### Proof.

###### Proposition I.3 .

###### Proof.

## Appendix J Complexity analysis

**Table 4: Model asymptotic runtime complexities.**
| Model | Complexity of a forward pass | Amortized complexity of a query |
| --- | --- | --- |
| HR-MPNNs | $\mathcal{O}(L(m|E|d+|V|d^{2}))$ | $\mathcal{O}(L(\frac{m|E|d}{|R||V|^{2}}+\frac{d^{2}}{|R||V|}+d))$ |
| HC-MPNNs | $\mathcal{O}(L(m|E|d+|V|d^{2}))$ | $\mathcal{O}(L(\frac{m|E|d}{|V|}+d^{2}))$ |

In this section, we discuss the asymptotic time complexity of HR-MPNN and HC-MPNN. For HC-MPNN, we consider the model instance of HCNet with $g_{r}^{(\ell)}$ being a *query-independent* diagonal linear map.
For HR-MPNN, we consider the model instance with the same updating function Up and relation-specific message function $\textsc{Msg}_{r}$ as the considered HCNet model instance, referred to as HRNet:

$$ $\displaystyle{\bm{h}}_{v}^{(0)}$ $\displaystyle=\mathbf{1}^{d}$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=\sigma\Big{(}{\bm{W}}^{(\ell)}\Big{[}{\bm{h}}_{v}^{(\ell)}\Big{ \|}\sum_{(e,i)\in E(v)}\Big{(}\odot_{j\neq i}(\alpha^{(\ell)}{\bm{h}}_{e(j)}^{ (\ell)}\!\!+(1-\alpha^{(\ell)}){\bm{p}}_{j})\odot{\bm{w}}_{r}^{(\ell)}\Big{)} \Big{]}+{\bm{b}}^{(\ell)}\Big{)}.$ $$

Notation.
Given a relational hypergraph $G=(V,E,R,c)$, we denote $|V|,|E|,|R|$ to be the size of vertices, edges, and relation types. $d$ is the hidden dimension and $m$ is the maximum arity of the edges. Additionally, we denote $L$ to be the total number of layers, and $k$ to be the arity of the query relation $q\in R$ in the query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$.

Analysis.
Given a query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$, the runtime complexity of a single forward pass of HCNet is $O(L(m|E|d+|V|d^{2}))$ since for each message, we need $O(d)$ for the relation-specific transformation, and we have $m|E|$ total amount of message in each layer. During the updating function, we additionally need a linear transformation for each aggregated message as well as a self-transformation, which costs $O(d^{2})$ for each node. Adding them up, we have $O(m|E|d+|V|d^{2})$ cost for each layer, and thus $O(L(m|E|d+|V|d^{2}))$ in total.

Note that this is the same as the complexity of HRNet since the only differences lie in initialization methods, which is $O(|V|d)$ cost for HCNet. In terms of computing a single query, the amortized complexity of HCNet is $O(L(\frac{m|E|d}{|V|}+d^{2}))$ since in each forward pass, $|V|$ number of queries are computed at the same time. In contrast, HRNet computes $|V|^{k}$ query as once it has representations for all nodes in the relational hypergraph, it can compute all possible hyperedges by permuting the nodes and feeding them into the $k$-ary decoder. We summarize the complexity analysis in Table 4.

## Appendix K Transductive experiments

In this section, we also carry out transductive link prediction experiments on benchmark datasets with relational hypergraphs to showcase the empirical strong performance of HCNets.

**Table 5: Results of transductive link prediction experiments. We report averaged MRR, Hits@1, Hits@3, and Hits@10 (higher is better) on test sets together with its standard deviation.**
|  | JF17K | FB-AUTO |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | MRR | Hits@1 | Hits@3 | Hits@10 | MRR | Hits@1 | Hits@3 | Hits@10 |
| r-SimplE | 0.102 | 0.069 | 0.112 | 0.168 | 0.106 | 0.082 | 0.115 | 0.147 |
| m-DistMult | 0.463 | 0.372 | 0.510 | 0.634 | 0.784 | 0.745 | 0.815 | 0.845 |
| m-CP | 0.391 | 0.298 | 0.443 | 0.563 | 0.752 | 0.704 | 0.785 | 0.837 |
| m-TransH | 0.444 | 0.370 | 0.475 | 0.581 | 0.728 | 0.727 | 0.728 | 0.728 |
| HSimplE | 0.472 | 0.378 | 0.520 | 0.645 | 0.798 | 0.766 | 0.821 | 0.855 |
| HypE | 0.494 | 0.408 | 0.538 | 0.656 | 0.804 | 0.774 | 0.823 | 0.856 |
| GETD | 0.151 | 0.104 | 0.151 | 0.258 | 0.367 | 0.254 | 0.422 | 0.601 |
| BoxE | 0.560 | 0.472 | 0.604 | 0.722 | 0.844 | 0.814 | 0.863 | 0.898 |
| ReAIE | 0.530 | 0.454 | 0.563 | 0.677 | 0.861 | 0.836 | 0.877 | 0.908 |
| G-MPNN | 0.501 | 0.425 | 0.537 | 0.660 | - | - | - | - |
| RD-MPNN | 0.512 | 0.445 | 0.573 | 0.685 | 0.810 | 0.714 | 0.880 | 0.888 |
| HCNet | 0.540 $\pm$ 0.002 | 0.440 $\pm$ 0.001 | 0.595 $\pm$ 0.007 | 0.730 $\pm$ 0.006 | 0.871 $\pm$ 0.005 | 0.842 $\pm$ 0.007 | 0.892 $\pm$ 0.003 | 0.922 $\pm$ 0.005 |

Datasets & Baselines. We evaluate HCNets on the link prediction task with relational hypergraphs, namely the publicly available JF17K [], following the standard train-valid-test split provided in Fatemi et al. [], and FB-AUTO [].
These datasets include facts of different arities up to $6$. We have taken the results of r-SimplE, m-DistMult, m-CP, HSimplE, HypE, and m-TransH [] from Fatemi et al. [], BoxE from Abboud et al. [], G-MPNN [], GETD [] and ReAIE from Fatemi et al. [], and RD-MPNN from Zhou et al. []. We consider the query-dependent message function in experiments with JF17K, and the query-independent message function on FB-AUTO. The statistics of the datasets are reported in Table 11, and the hyper-parameter choices in Table 13. We also analyze the performance when testing with different arities on JF17K, reported in Table 6, Appendix L.
We report Mean Reciprocal Rank(MRR) and Hits@$k$ where $k=1,3,10$ as evaluation metrics, and provide averaged results of *five* runs on different seeds. We ran all transductive experiments on a single NVIDIA V100 GPU.

Results.
We summarize the results for the transductive link prediction tasks and report them in Table 5. HCNet is placed top in FB-AUTO on all metrics and is very competitive in JF17K, where it is top in Hits@$10$ and top 2 in MRR and Hits@$3$, outperforming most of the existing methods except BoxE,
which is designed specifically for the transductive setting. In particular, we observe that on almost all metrics in both datasets, HCNet outperforms RD-MPNN and G-MPNN, which are all HR-MPNN instances, empirically validating our theory and proving that HCNet is also effective in the transductive setting.

**Table 6: Performance breakdown of Hits@$10$ of our model with different arities on the JF17K dataset.**
| Model | Arity | All |  |  |
| --- | --- | --- | --- | --- |
| 2 | 3 | $4-5-6$ |  |  |
| m-DistMult | 0.495 | 0.648 | 0.809 | 0.634 |
| m-CP | 0.409 | 0.563 | 0.765 | 0.560 |
| m-TransH | 0.411 | 0.617 | 0.826 | 0.596 |
| HSimplE | 0.497 | 0.699 | 0.745 | 0.645 |
| HypE | 0.466 | 0.693 | 0.858 | 0.656 |
| RD-MPNN | 0.476 | 0.716 | 0.934 | 0.685 |
| HCNet | 0.557 | 0.768 | 0.934 | 0.730 |

## Appendix L Analysis on different arities

We evaluate the performance of different arities for transductive experiments on JF17K dataset. We take the reported model of HCNet, and adopt the same evaluation setup but with a separation of tuples with different arities. We report the performance for each arity in Table 6.

Results. We observe consistently top performance of HCNet on all arities. These results underscore that HCNet has robust capability in reasoning over relational hypergraphs. In particular, we observe a trend that HCNets are more powerful when evaluating relation with lower arity. This is especially helpful since the majority of the hyperedges in the relational hypergraphs have their relation being relatively low arities. Nevertheless, HCNet still produces state-of-the-art performance on high-arity tuples, demonstrating its effectiveness in link prediction with relational hypergraphs.

## Appendix M Experiments on inductive link prediction with knowledge graphs

We carry out additional inductive experiments on knowledge graphs where each edge has its arity fixed to $2$ and compare the results against the current state-of-the-art models.

Setup. We evaluate HCNet on $4$ standard inductive splits of WN18RR [] and FB15k-237 [], which was proposed in Teru et al. []. We provide the details of the datasets in Table 8. Contrary to the standard experiment setting [, ] on knowledge graph $G=(V,E,R,{\bm{x}})$ where for each relation $r(u,v)\in E$, an inverse-relation $r^{-1}$ is introduced as a fresh relation symbol and $r^{-1}(v,u)$ is added in the knowledge graph, in our setup we do *not* augment inverse edges for HCNet. This makes the task more challenging. We compare HCNet with models designed *only* for inductive binary link prediction task with knowledge graphs, namely GraIL [], NeuralLP [], DRUM [], NBFNet [], RED-GNN [], and A*Net [], and we take the results provided in Zhu et al. [] for comparison.

Implementation. We report the hyperparamter used in Table 9. For all models, we consider a 2-layer MLP as
decoder and adopt layer-normalization with dropout in all
layers before applying ReLU activation and skip-connection.
We also adopt the sinusoidal positional encoding as described in the body of the paper.
We discard all the edges in the training graph that are currently being treated as positive triplets in each batch to prevent overfitting.
We additionally pass in the considered query representation ${\bm{z}}_{q}$ to the decoder via concatenation to ${\bm{h}}_{v|{\bm{q}}}^{(L)}$.
The best checkpoint for each model is selected based on its performance on the validation sets, and
all experiments are performed on one NVIDIA A10 24GB GPU. For evaluation, we consider *filtered ranking protocol* [] with $32$ negative samples per positive triplet, and report Hits@$10$ for each model.

Results.
We report the results in Table 7. We observe that HCNets are highly competitive even compared with state-of-the-art models specifically designed for link prediction with knowledge graphs. HCNets reach the top $3$ for $7$ out of $8$ datasets, and obtain a very close result for the final dataset.
Note here that the top $2$ models are NBFNet [] and A*Net [], which share a similar idea of HCNet and are all based on conditional message passing. The difference in results lies in the different message functions, which are further supported in Table 1 of Huang et al. [].

However, we highlight that HCNet does *not* augment with inverse relation edges, as described in the set-up of the experiment. HCNet can recognize the directionality of relational edges and pay respect to both incoming and outgoing edges during message passing. No current link prediction model based on message passing can explicitly take care of this without edge augmentation. In fact, Theorem H.4 implies that all current models based on conditional message passing, including NBFNets, need inverse relation augmentation to match the expressive power of HCNet.
Theoretically speaking, this allows us to claim that HCNet is strictly more powerful than all other models in the baseline that are based on conditional message passing, assuming all considered models are expressive enough to match their corresponding relational Weisfeiler-Leman test.

**Table 7: Binary inductive experiment on knowledge graph for Hits@10 result. The best result is in bold, and second/third best in underline.**
| Method | FB15k-237 | WN18RR |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| v1 | v2 | v3 | v4 | v1 | v2 | v3 | v4 |  |
| GraIL | 0.429 | 0.424 | 0.424 | 0.389 | 0.760 | 0.776 | 0.409 | 0.687 |
| NeuralLP | 0.468 | 0.586 | 0.571 | 0.593 | 0.772 | 0.749 | 0.476 | 0.706 |
| DRUM | 0.474 | 0.595 | 0.571 | 0.593 | 0.777 | 0.747 | 0.477 | 0.702 |
| NBFNet | 0.574 | 0.685 | 0.637 | 0.627 | 0.826 | 0.798 | 0.568 | 0.694 |
| RED-GNN | 0.483 | 0.629 | 0.603 | 0.621 | 0.799 | 0.780 | 0.524 | 0.721 |
| A*Net | 0.589 | 0.672 | 0.629 | 0.645 | 0.810 | 0.803 | 0.544 | 0.743 |
| HCNet | 0.566 | 0.646 | 0.614 | 0.610 | 0.822 | 0.790 | 0.536 | 0.724 |

**Table 8: Dataset statistics for the inductive relation prediction experiments. #Query* is the number of queries used in the validation set. In the training set, all triplets are used as queries.**
| Dataset |  | #Relation | Train & Validation | Test |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| #Nodes | #Triplet | #Query* | #Nodes | #Triplet | #Query |  |  |  |
| WN18RR | $v_{1}$ | 9 | 2,746 | 5,410 | 630 | 922 | 1,618 | 188 |
| $v_{2}$ | 10 | 6,954 | 15,262 | 1,838 | 2,757 | 4,011 | 441 |  |
| $v_{3}$ | 11 | 12,078 | 25,901 | 3,097 | 5,084 | 6,327 | 605 |  |
| $v_{4}$ | 9 | 3,861 | 7,940 | 934 | 7,084 | 12,334 | 1,429 |  |
| FB15k-237 | $v_{1}$ | 180 | 1,594 | 4,245 | 489 | 1,093 | 1,993 | 205 |
| $v_{2}$ | 200 | 2,608 | 9,739 | 1,166 | 1,660 | 4,145 | 478 |  |
| $v_{3}$ | 215 | 3,668 | 17,986 | 2,194 | 2,501 | 7,406 | 865 |  |
| $v_{4}$ | 219 | 4,707 | 27,203 | 3,352 | 3,051 | 11,714 | 1,424 |  |

**Table 9: Hyperparameters for binary inductive experiments with HCNet.**
| Hyperparameter | WN18RR | FB15k-237 |  |
| --- | --- | --- | --- |
| GNN Layer | Depth$(L)$ | $6$ | $6$ |
| Hidden Dimension | $32$ | $32$ |  |
| Decoder Layer | Depth | $2$ | $2$ |
| Hidden Dimension | $64$ | $64$ |  |
| Optimization | Optimizer | Adam | Adam |
| Learning Rate | 5e-3 | 5e-3 |  |
| Learning | Batch size | $32$ | $32$ |
| #Negative Samples | $32$ | $32$ |  |
| Epoch | $30$ | $30$ |  |
| #Batch Per Epoch | $-$ | $-$ |  |
| Adversarial Temperature | $0.5$ | $0.5$ |  |
| Dropout | $0.2$ | $0.2$ |  |
| Accumulation Iteration | $1$ | $1$ |  |

Figure: Figure 5: An example relational hypergraph of dataset HyperCycle, where $n=8$ and $k=3$. We colored $r_{1}$ as blue and $r_{2}$ as red. The goal is to predict the black edge as true but the gray edge as false. We claim that no HR-MPNNs can correctly solve this task, but HCNets can.

## Appendix N Synthetic experiments

We carry out a synthetic experiment with a custom-built dataset HyperCycle to showcase that HC-MPNNs are more expressive than HR-MPNNs in the task of link prediction with relational hypergraphs.

Dataset. We construct HyperCycle, a synthetic dataset that consists of multiple relational hypergraphs with relation $R=\{r_{0},r_{1},r_{2}\}$. Each relational hypergraph $G$ is parameterized by 2 hyperparameters: the number of nodes $n$ which is always a multiple of $4$, and the arity of each edge $k$. Given such $(n,k)$ pair, we generate the relational hypergraph $G(n,k)=(V(n,k),E(n,k),R(n,k))$ where

$$ $\displaystyle V(n,k)$ $\displaystyle=\{x_{1},\cdots,x_{n}\}$ $\displaystyle E(n,k)$ $\displaystyle=\{r_{(i\bmod 2)+1}(x_{(i+j)\bmod n}\mid 0\leq j<k)\mid 1\leq i \leq n\}$ $\displaystyle R(n,k)$ $\displaystyle=\{r_{0},r_{1},r_{2}\}$ $$

In short, there is a directed hyper-edge of arity $k$ with alternating relations between $r_{1}$ and $r_{2}$ for all $k$ consecutive nodes in this cycle. We present one example of such relational hypergraph in Figure 5, where $n=8$ and $k=3$. We generate the dataset by choosing $n=\{8,12,16,20\}$ and $k=\{3,4,5,6,7\}$. We then randomly pick 70% of the generated graphs as the training set and the remaining 30% as the testing set.

Objective. The objective of this task is for each node to identify the node that is located at the “opposite point” in the cycle of the given node as true. Formally speaking, for a relational hypergraph $G(n,k)$, we want to predict a $2$-ary (hyper-)edge of relation $r_{0}$ between any node $x_{i}$ and its “opposite point” $x_{(i+n/2\bmod n)}$ for all $1\leq i\leq n$, i.e., classify $r_{0}(x_{i},x_{(i+n/2)\bmod n})$ as true. The negative sample is generated by considering the $r_{0}$ relation (hyper-)edges that connect the “2-hop” neighboring node, i.e., classify $r_{0}(x_{i},x_{(i+2)\bmod n})$ as false. Note that since $n\neq 4$, we will never have $(i+n/2)\bmod n=(i+2)\bmod n$.

Model architectures. We considered two model architectures, namely an HC-MPNN instance HCNet:

$$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(0)}$ $\displaystyle=\sum_{i\neq t}\mathbbm{1}_{v=u_{i}}*({\bm{p}}_{i}+{\bm{z}}_{q})$ $\displaystyle{\bm{h}}_{v|{\bm{q}}}^{(\ell+1)}$ $\displaystyle=\sigma\Big{(}{\bm{W}}^{(\ell)}\Big{[}{\bm{h}}_{v|{\bm{q}}}^{( \ell)}\Big{\|}\sum_{(e,i)\in E(v)}\Big{(}\odot_{j\neq i}(\alpha^{(\ell)}{\bm{h }}_{e(j)|{\bm{q}}}^{(\ell)}\!\!+(1-\alpha^{(\ell)}){\bm{p}}_{j})\odot{\bm{w}}_ {r}^{(\ell)}\Big{)}\Big{]}+{\bm{b}}^{(\ell)}\Big{)}.$ $$

and a corresponding HR-MPNNs instance called HRNet that shares the same *update*, *aggregate*, and relation-specific *message* functions as in HCNet, defined as follow:

$$ $\displaystyle{\bm{h}}_{v}^{(0)}$ $\displaystyle=\mathbf{1}^{d}$ $\displaystyle{\bm{h}}_{v}^{(\ell+1)}$ $\displaystyle=\sigma\Big{(}{\bm{W}}^{(\ell)}\Big{[}{\bm{h}}_{v}^{(\ell)}\Big{ \|}\sum_{(e,i)\in E(v)}\Big{(}\odot_{j\neq i}(\alpha^{(\ell)}{\bm{h}}_{e(j)}^{ (\ell)}\!\!+(1-\alpha^{(\ell)}){\bm{p}}_{j})\odot{\bm{w}}_{r}^{(\ell)}\Big{)} \Big{]}+{\bm{b}}^{(\ell)}\Big{)}.$ $$

Note that $\sigma$ stands for the ReLU activation function in both models. We additionally use a binary MLP decoder for HRNet, which takes the concatenation of the final representation for each entity in the query, together with the learnable query vector ${\bm{z}}_{q}$ to obtain the final probability.

Design. We claim that HCNet can correctly predict all the testing triplets, whereas HRNet fails to learn this pattern and will only achieve $50\%$ accuracy, which is no better than random guessing. This is exactly due to the lack of expressiveness of HR-MPNNs by relying on a $k$-ary decoder for link prediction. Theoretically, all nodes of the relational hypergraphs in HyperCycle, due to their rotational symmetry introduced by alternating relation types $r_{1},r_{2}$, can be partitioned into two sets. Since the nodes within each set are isomorphic to each other, it is impossible for any HR-MPNNs to distinguish between these nodes by only computing its unary invariant. Thus HR-MPNNs cannot possibly solve this task, as whenever they classify the target “opposite point” node to be true, they also have to classify the “2-hop” node to be true, and vice versa.

However, HCNet can bridge this gap by introducing the relevant notion of “distance”. As HCNet carries out message-passing after identifying the source node, the relative distance between the source node and the target “opposite point” node will be different than the one with the “2-hop” node. Thus, by keeping track of the distance from the source node, HCNet will compute a different embedding for the positive triplet and the negative triplet, effectively solving this task.

Experimental details. For both models, we use $7$ layers, each with $32$ hidden dimensions. We configure the learning rate to be 1e-3 for both models and train them for 100 epochs. Empirically, we observe that HCNet easily reaches $100\%$ accuracy, solving this task completely, whereas HRNet always fails to learn anything meaningful, reaching an accuracy of $50\%$. The experiment results are consistent with our theory.

## Appendix O Further experiment details

We report the details of the experiment carried out in the body of the paper in this section. In particular, we report the dataset statistics of the inductive link prediction task in Table 10 and of the transductive link prediction task in Table 11. We also report the hyperparameter used for HCNet in the inductive link prediction task at Table 12 and transductive link prediction task at Table 13, respectively. In addition, we report additionally the standard deviation for the main experiments in Table 14, the complete tables for the ablation study mentioned in Table 15 and Table 16, the detailed definitions of initialization and positional encoding considered in Table 17 and Table 18, respectively. Finally, we report the execution time and GPU usages for $1$ epochs of HCNets on all datasets considered in the paper with corresponding hyperparameters in Table 19.

We adopt the *partial completeness assumption* [] on relational hypergraphs, where we randomly corrupt the $t$-th position of a $k$-ary fact $q(u_{1},\cdots,u_{k})$ each time for $1\leq t\leq k$. HCNets minimize the negative log-likelihood of the positive fact presented in the training graph, and the negative facts due to corruption. We represent query ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$ as the fact $q(u_{1},\cdots,u_{k})$ given corrupting $t$-th position, and represent its conditional probability as $p(v|{\bm{q}})=\sigma(f({\bm{h}}_{v|{\bm{q}}}^{(L)}))$, where $v\in V$ is the considered entity in the $t$-th position, $L$ is the total number of layer, $\sigma$ is the sigmoid function, and $f$ is a 2-layer MLP. We then adopt *self-adversarial negative sampling* [] by sampling negative triples from the following distribution:

$$ ${\mathcal{L}}(v\mid{\bm{q}})=-\log p(v\mid{\bm{q}})-\sum_{i=1}^{n}w_{i,\alpha} \log(1-p(v_{i}^{\prime}\mid{\bm{q}}))\\$ $$

where $\alpha$ is the adversarial temperature as part of the hyperparameter, $n$ is the number of negative samples for the positive sample and $v^{\prime}_{i}$ is the $i$-th corrupted vertex of the negative sample. Finally, $w_{i}$ is the weight for the $i$-th negative sample, given by

$$ $w_{i,\alpha}:=\operatorname{Softmax}\left(\frac{\log(1-p(v_{i}^{\prime}\mid{ \bm{q}}))}{\alpha}\right).$ $$

**Table 10: Dataset statistics of inductive link prediction task with relational hypergraph.**
| Dataset | # seen vertices | # train hyperedges | # unseen vertices | # relations | # features | # max arity |
| --- | --- | --- | --- | --- | --- | --- |
| WP-IND | 4,363 | 4,139 | 100 | 32 | 37 | 4 |
| JF-IND | 4,685 | 6,167 | 100 | 31 | 46 | 4 |
| MFB-IND | 3,283 | 336,733 | 500 | 12 | 25 | 3 |

**Table 11: Dataset statistics of transductive link prediction task with relational hypergraph on JF17K and FB-AUTO with respective arity.**
| Dataset | JF17K | FB-AUTO |
| --- | --- | --- |
| $|V|$ | 29,177 | 3,410 |
| $|R|$ | 327 | 8 |
| #train | 61,104 | 6,778 |
| #valid | 15,275 | 2,255 |
| #test | 24,915 | 2,180 |
| # arity=2 | 56,322 | 3,786 |
| # arity=3 | 34,550 | 0 |
| # arity=4 | 9,509 | 215 |
| # arity=5 | 2,230 | 7,212 |
| # arity=6 | 37 | 0 |

**Table 12: Hyperparameters for inductive experiments of HCNet.**
| Hyperparameter | WP-IND | JF-IND | MFB-IND |  |
| --- | --- | --- | --- | --- |
| GNN Layer | Depth$(L)$ | $5$ | $5$ | $4$ |
| Hidden Dimension | $128$ | $256$ | $32$ |  |
| Decoder Layer | Depth | $2$ | $2$ | $2$ |
| Hidden Dimension | $128$ | $256$ | $32$ |  |
| Optimization | Optimizer | Adam | Adam | Adam |
| Learning Rate | 5e-3 | 1e-2 | 5e-3 |  |
| Learning | Batch size | $32$ | $32$ | $1$ |
| #Negative Sample | $10$ | $10$ | $10$ |  |
| Epoch | $20$ | $20$ | $10$ |  |
| #Batch Per Epoch | - | - | $10000$ |  |
| Adversarial Temperature | $0.5$ | $0.5$ | $0.5$ |  |
| Dropout | $0.2$ | $0.2$ | 0 0 |  |
| Accumulation Iteration | $1$ | $1$ | $32$ |  |

**Table 13: Hyperparameters for transductive experiments of HCNet.**
| Hyperparameter | JF17K | FB-AUTO |  |
| --- | --- | --- | --- |
| GNN Layer | Depth$(L)$ | $6$ | $4$ |
| Hidden Dimension | $64$ | $128$ |  |
| Decoder Layer | Depth | $2$ | $2$ |
| Hidden Dimension | $64$ | $128$ |  |
| Optimization | Optimizer | Adam | Adam |
| Learning Rate | 5e-3 | 1e-3 |  |
| Learning | Batch size | $1$ | $32$ |
| #Negative Sample | $50$ | $32$ |  |
| Epoch | $6$ | $20$ |  |
| #Batch Per Epoch | $-$ | $-$ |  |
| Adversarial Temperature | $0.5$ | $0.5$ |  |
| Dropout | $0.2$ | $0.2$ |  |
| Accumulation Iteration | $32$ | $1$ |  |

**Table 14: Results of inductive link prediction experiments. We report averaged MRR, Hits@$1$, and Hits@$3$ (higher is better) on test sets together with its standard deviation.**
|  | WP-IND | JF-IND | MFB-IND |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|  | MRR | Hits@1 | Hits@3 | MRR | Hits@1 | Hits@3 | MRR | Hits@1 | Hits@3 |
| HGNN | 0.072 | 0.045 | 0.112 | 0.102 | 0.086 | 0.128 | 0.121 | 0.076 | 0.114 |
| HyperGCN | 0.075 | 0.049 | 0.111 | 0.099 | 0.088 | 0.133 | 0.118 | 0.074 | 0.117 |
| G-MPNN-sum | 0.177 | 0.108 | 0.191 | 0.219 | 0.155 | 0.236 | 0.124 | 0.071 | 0.123 |
| G-MPNN-mean | 0.153 | 0.096 | 0.145 | 0.112 | 0.039 | 0.116 | 0.241 | 0.162 | 0.257 |
| G-MPNN-max | 0.200 | 0.125 | 0.214 | 0.216 | 0.147 | 0.240 | 0.268 | 0.191 | 0.283 |
| HCNet | 0.414 $\pm$ 0.005 | 0.352 $\pm$ 0.004 | 0.451 $\pm$ 0.005 | 0.435 $\pm$ 0.017 | 0.357 $\pm$ 0.023 | 0.495 $\pm$ 0.014 | 0.368 $\pm$ 0.015 | 0.223 $\pm$ 0.014 | 0.417 $\pm$ 0.022 |

**Table 15: Results of ablation study experiments on initialization. We report MRR, Hits@$1$, and Hits@$3$ (higher is better) on test sets.**
| Init | WP-IND | JF-IND |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| ${\bm{z}}_{q}$ | ${\bm{p}}_{i}$ | MRR | Hits@1 | Hits@3 | MRR | Hits@1 | Hits@3 |
| - | - | 0.388 | 0.324 | 0.421 | 0.390 | 0.295 | 0.451 |
| ✓ | - | 0.387 | 0.321 | 0.421 | 0.392 | 0.302 | 0.447 |
| - | ✓ | 0.394 | 0.329 | 0.430 | 0.393 | 0.300 | 0.456 |
| ✓ | ✓ | 0.414 | 0.352 | 0.451 | 0.435 | 0.357 | 0.495 |

**Table 16: Results of ablation study experiments on positional encoding. We report MRR, Hits@$1$, and Hits@$3$ (higher is better) on test sets.**
| PE | WP-IND | JF-IND |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| MRR | Hits@1 | Hits@3 | MRR | Hits@1 | Hits@3 |  |
| Constant | 0.393 | 0.328 | 0.426 | 0.356 | 0.247 | 0.428 |
| One-hot | 0.395 | 0.334 | 0.428 | 0.368 | 0.275 | 0.432 |
| Learnable | 0.396 | 0.335 | 0.425 | 0.416 | 0.335 | 0.480 |
| Sinusoidal | 0.414 | 0.352 | 0.451 | 0.435 | 0.357 | 0.495 |

**Table 17: Definition of Init in the ablation study of initialization. Here, ${\bm{q}}=(q,\tilde{{\bm{u}}},t)$, and $d$ is the hidden dimension before passing to the first layer.**
| Init | ${\bm{h}}_{v|{\bm{q}}}^{(0)}$ |  |
| --- | --- | --- |
| ${\bm{z}}_{q}$ | ${\bm{p}}_{i}$ |  |
| - | - | $\sum_{i\neq t}\mathbbm{1}_{v=u_{i}}*\mathbf{1}^{d}$ |
| ✓ | - | $\sum_{i\neq t}\mathbbm{1}_{v=u_{i}}*{\bm{p}}_{i}$ |
| - | ✓ | $\sum_{i\neq t}\mathbbm{1}_{v=u_{i}}*{\bm{z}}_{q}$ |
| ✓ | ✓ | $\sum_{i\neq t}\mathbbm{1}_{v=u_{i}}*({\bm{p}}_{i}+{\bm{z}}_{q})$ |

**Table 18: Definition of ${\bm{p}}_{i}$ in the ablation study of positional encoding. Here, $\mathbb{I}_{i}^{d}$ is the one-hot vector of $d$ dimension where only the index $i$ has entry $1$ and the rest 0 0. Note that $d$ is the hidden dimension before passing to the first layer. $\hat{{\bm{p}}}$ is a $d$-dimensional learnable vectors. ${\bm{p}}_{i,j}$ is the $j$-th index of position encoding ${\bm{p}}_{i}$, and $d$ is the dimension of the vector ${\bm{p}}_{i}$.**
| PE |  |
| --- | --- |
| Constant | ${\bm{p}}_{i}=\mathbf{1}^{d}$ |
| One-hot | ${\bm{p}}_{i}=\mathbb{I}_{i}^{d}$ |
| Learnable | ${\bm{p}}_{i}=\hat{{\bm{p}}}_{i}$ |
| Sinusoidal | ${\bm{p}}_{i,2j}=\sin\left(\frac{i}{10000^{2j/d}}\right)$;<br>${\bm{p}}_{i,(2j+1)}=\cos\left(\frac{i}{10000^{2j/d}}\right)$ |

**Table 19: Execution time of $1$ epoch and GPU memory used for inductive and transductive link prediction task with relational hypergraph, using a single A10 GPU. Note that we use batch size $=1$ during testing.**
| Dataset | Training time | Testing time | GPU usages |
| --- | --- | --- | --- |
| WP-IND | 3.5min | 18 sec | 10GB |
| JF-IND | 8min | 10 sec | 20GB |
| MFB-IND (10k steps) | 80 min | 3.5 min | 12.9 GB |
| JF17K | 8hr | 7hr | 9GB |
| FB-AUTO | 4.5min | 4min | 8GB |

## Appendix P Social impact

This work mainly focused on link prediction with relational hypergraphs, which has a wide range of applications and thus many potential societal impacts. One potential negative impact is the enhancement of malicious network activities like phishing or pharming through the use of powerful link prediction models. We encourage further studies to mitigate these issues.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: 1. Does a relational hyperedge have a fixed number of entities? For example, can we have r(e1, e2) and r(e1, e2, e3) at the same time? 
2. How to train the model with queries?
soundness: 2
strengths: 1. The paper is written in a good structure. Although the definition of the relational hypergraph is a little bit complex; the descriptions in the paper is not difficult to understand. The organization of the paper is good. From the theoretic analysis to model improvement, the techniques are quite clear.

2. Extending the C-MPNN and HR-MPNN to HC-MPNN is technically sound. And the extension to inductive link prediction is interesting.

3. Both theoretic analysis and experiments are comprehensive. It has with both inductive and transductive settings, and the analysis of the initialization and positional encoding is also useful.
summary: This paper proposes a new method for link prediction in relational hypergraphs, where the task focuses on k-ary relations. It first investigates the expressive power of existing GNNs for relational hypergraphs, and then introduces the hypergraph conditional message passing neural network (HC-MPNN) by utilizing and extending the techniques from conditional message passing neural networks (C-MPNNs) (Huang et al., 2023). The HC-MPNN is further extended to an inductive setting, and show good experimental results.
weaknesses: 1. First, I have a concern about the practicality of the method. From my understanding, the relational hyperedge is just like a sentence, and it has fixed directions and positions for entities. So, why do not people just use Transformers for NLP by regarding the relational hyperedge as a sentence? And the query based approach is just like a BERT-based model? I do not see much benefit from modeling it as a hypergraph. I am actually curious to see the results of BERT on the same datasets if possible. 

2. Second, although the paper is technically sound and the analysis is complete/rigorious; but every step in the model is not surprising and a little bit trivial. Without the analysis part, the HC-MPNN is like just a migration of C-MPNN to hypergraphs. The inductive link prediction part is more interesting. 

3. I do not fully understand the training. Since the message passing is query dependent, there must be a lot of queries in the training data. How do you select such queries for training? And for each query, the node representation is different, does not it increase the computational complexity a lot?

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 3
questions: I would like the authors to continue discussing the disagreement over C2, explaining why they insist that relational hypergraphs and hyper-relational graphs have irreconcilable differences. In my view, even if their structures are not identical, small modifications could allow format conversion. The benefits of doing so include:

	1.	Making the proposed method more generalized and applicable to a broader range of scenarios.
	2.	Aligning with many previous studies in the field.
soundness: 3
strengths: S1. Clear and well-organized presentation of the whole paper.

S2. Solid proof of the theoretical expressiveness of the proposed method.

S3. Available code.

S4. Transductive experiments have been added.
summary: The authors first give an understanding of the expressive power and limitations of HR-MPNNs and propose the HC-MPNN structure based on HR-MPNN. Compared with current HR-MPNN models, the HC-MPNN structured model HCNet carries out a novel query-specific node initialization method. With the Weisfeiler-Leman test, the author proves that this model can better model isomorphic nodes since it maintains a better expressiveness than the HR-MPNN structured models in the relational hypergraphs.
weaknesses: Unfortunately for the authors, I am the reviewer who held a negative opinion on this paper for NeurIPS 2024. Here, I summarize my previous negative feedback:

**Major Concerns:**

C1. The theoretical proof in this paper is unrelated to the inductive setting. Previously, I hoped the authors would compare more transductive settings. This time, **Table 2 has addressed this concern quite well**. Thus, I decided to raise my score.

C2. I previously argued that hyper-relational graphs and relational hypergraphs can be converted with small tricks, which is why many prior studies conducted experiments on datasets like WD50K, WIKIPEOPLE, JF17K, and FBAuto. Therefore, I also suggested that the authors consider experimenting on other hyper-relational graphs. However, the authors hold a different view, and the explanation provided in lines 145-153 is not sufficient to alleviate my concern. Thus, I will retain my suggestion for this submission and discuss it further with other reviewers.

**Minor Concerns:**

C3. Many of the methods presented in Table 1 were published in or before 2020, which may imply that the inductive setting is not currently a major research focus. The authors may need to emphasize the significance of the inductive setting more in the paper.

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 3
questions: - **Expressiveness Limitations**: Could the authors provide more details on situations or graph structures where the expressive power of HC-MPNNs might fall short, even with the enhanced encoding?
- **Impact of Hypergraph Structure**: How does the structure or density of a hypergraph affect the model’s performance, especially in cases of sparse or highly connected hypergraphs?
- **Generalization to Noisy Data**: How robust is HC-MPNN to noisy or incomplete hypergraph data, and are there mechanisms in place to handle such cases?
- **Positional Encoding Variants**: The ablation studies show sinusoidal positional encoding as the best choice. Could the authors elaborate on why this is effective in hypergraph contexts compared to other embeddings?
- **Use of Meta-Paths**: Given that meta-paths are important structures in relational (non-hypergraph) graphs [1, 2, 3], could there be advantages to incorporating them in hypergraph contexts?
- **Scalability of the Model**: Is the model feasible to apply in very large-scale hypergraphs (e.g., millions of nodes)? 

[1] Seongjun, Y. et al., Graph Transformer Networks: Learning meta-path graphs to improve GNNs, 2022

[2] Ferrini, F. et al., Meta-Path Learning for Multi-relational Graph Neural Networks, LOG 2023

[3]Fu, Xinyu, et al. "Magnn: Metapath aggregated graph neural network for heterogeneous graph embedding." Proceedings of the web conference 2020. 2020.
soundness: 3
strengths: - **Innovative Approach**: The paper introduces Hypergraph Conditional Message Passing Neural Networks (HC-MPNNs), which generalize existing GNN architectures and target the complex task of k-ary link prediction on relational hypergraphs, moving beyond traditional binary link prediction tasks.
- **Theoretical Rigor**: The authors provide a detailed analysis of HC-MPNNs' expressive power through Weisfeiler-Leman tests and logical expressiveness, which significantly adds to the theoretical foundation of GNNs on hypergraphs.
- **State-of-the-Art Performance**: Empirical results demonstrate that HC-MPNNs outperform existing models for both inductive and transductive link prediction tasks across multiple datasets, showcasing substantial improvements.
summary: The paper introduces HC-MPNNs, a novel GNN architecture for link prediction on relational hypergraphs, achieving state-of-the-art results in both inductive and transductive tasks. While highly expressive, the model faces scalability challenges due to its computational complexity.
weaknesses: - **Computational Complexity**: The paper acknowledges that the proposed HC-MPNNs may be computationally intensive, particularly for large hypergraphs. An in-depth analysis of the computational costs compared to baseline models is needed to assess scalability better.
- **Limited Scope**: The model is focused solely on link prediction. Exploring its applicability to other tasks, such as node classification or hypergraph-based query answering, would provide more versatility and impact.
- **Assumptions on Data Structure**: The approach assumes that hypergraph structures are available and complete, which may not always be feasible in real-world scenarios. The limitations of applying this method to noisy or partially observed hypergraphs are not discussed.

---

confidence: 3
contribution: 2
initial_rating: 6
presentation: 3
questions: - I am not familiar with the background of link prediction on relational hypergraph, thus I have questions to the necessity of this problem: It seems that the hyper relation prediction can be decomposed into prediction over a relational path or subgraph, and all three benchark you used seems to built from conventional knowledege graph, thus I am wondering is there a real-world dataset or task where only relational hypergraph methods can handle, and can not be decomposed into conventional relational graph methods?
- Since your method is transductive on relations, can we simply treat each relation as an independent node, and use the hyper relation position as edge attribute between a node and the relation node (e.g., $r(u_k)$ becomes $u_k \overset{k}{\leftrightarrow} r$), thus we can convert this task into a classifition task over multiple edges on conventional graph? Is there any baselines corresponding to this idea?
- Is the order essential in hyper relations? I think it is possible to permute some node positions while not hurts the hyper relation? If so, isn't your definition too strict?
- I think predicting the relation also falls into link prediction catalog, but your link prediciton only focuses on nodes, is it defined only for this work?
- In refinement, I think you want to define $\xi$ is more expressive than $\xi'$ (can distinguish more cases), thus isn't $\xi' \prec \xi$ better than $\xi \prec \xi'$ in representing which one is more expressive?
- How is your method runtime in real-world training and inference? NBFNet is already expensive since the graph convolution has to be redo if the query change, and in your case, hyperedge may introduce exponential increase on the amount of neighbors.
soundness: 3
strengths: - This works have concrete theoretical justifications on both graph representation and knowledege graph domains including WL test (for relational hypergraph) and power of logical reasoning.
- The empirical result looks pretty good in compare to related works on relational hypergraph baselines.
summary: This work proposes HCNet, which extends state-of-the-art NBFNet and C-MPNN of conventional graph for link prediction to relational hypergraphs for hyper-relation predictions. It first follows the schema of conventional graph neural network works, defines the invariance under relational hypergraph and proves the expressivity of their proposal using proposed WL test for relational hypergraph. Then, it follows the schema of knowledge graph works, proves that the logical reasoning ability of HCNet is same as grade model logic on hypergraph. Besides, this work achieves better empirical results on relational hypergraph benchmarks.
weaknesses: - Although this work made enough refinement to adpat NBFNet and C-MPNN design onto relational hypergraph, there isn't significiant novelty introduced in the refinement: they are simply directly replace the concepts from conventional graph to relational hypergraph.
- For logical reasoning, I believe it should focus more on explainability to people, but the concept of graded modal logic for hypergraph (the definition and examples) in this paper is too abstract for people to understand their power. I think more evidence of HGML should be provided (in appendix), e.g., is it able to represent all logics or answer all logical queries on relational hypergraph? If not, what's the limitation?
- Since this is a neural network work and link prediction work (where negative sampling is necessary), they will be a lot randomness in experiments, thus it is essential to provide confidence interval at least to your works (I understand that some baselines do not have confidence interval).

Meta-review: This submission violated the anonymity policy. In the provided link (https://anonymous.4open.science/r/HCNet/README.md), when clicking the blue-colored text, Link Prediction with Relational Hypergraphs, the arXiv version of the paper is shown, which reveals all authors' information: https://arxiv.org/abs/2402.04062

This submission should have been desk-rejected. It was difficult to expect a redirection to the arXiv paper, so this clear violation was not found during the desk-rejecting period.

In addition to some of the reviewers' remaining concerns, I also found some critical issues based on my own reading:

1. **Misunderstandings of the relationship between relational hypergraphs and n-ary relational graphs.**\
The authors argue that "link prediction with relational hypergraphs is a more general problem setup" than that with n-ary relational graphs. However, I'm afraid I have to disagree with it. While a relational hyperedge can be transformed into an n-ary relational fact without loss of information, the reverse transformation is not always lossless. Given a hyperedge $r(u_1,u_2,u_3, u_4)$, it can be transformed into a 4-ary relational fact $\\{r_1:u_1, r_2:u_2, r_3:u_3, r_4:u_4\\}$ without loss of information. However, when we transform $\\{r_1:u_1, r_2:u_2\\}$ and $\\{r_1:u_3, r_2:u_4, r_3:u_5\\}$ into hyperedges, they are transformed into $r’_1(u_1, u_2)$ and $r’_2(u_3,u_4,u_5)$. In this conversion, the information loss occurs: the facts that $u_1$ and $u_3$ are both involved in $r_1$ and that $u_2$ and $u_4$ are both involved in $r_2$ are lost. Therefore, n-ary relational graphs are a more general form than relational hypergraphs.

2. **Mismatch of the concept of the relational hypergraph and benchmark datasets**\
The authors claim to "opt out datasets of hyper-relational knowledge graphs" and to "focus only on the datasets designed for relational hypergraphs". However, the datasets the authors used are extracted from knowledge bases such as Wikidata or Freebase, none of which are originally relational hypergraphs but in the form of n-ary relational graphs or hyper-relational knowledge graphs. While these datasets may have been adopted for evaluating methods targeting relational hypergraphs, their original structures do not perfectly align with the definition of relational hypergraphs. This mismatch renders these datasets unsuitable for evaluating methods designed specifically for relational hypergraphs. The authors should instead conduct experiments on datasets extracted from relational hypergraphs.

3. **Misunderstanding of the literature**\
The authors stated, "We also highlight the evaluation differences as experiments on hyper-relational knowledge graphs only corrupt entities in the main triplets, whereas, in link prediction with relational hypergraphs setting, all entities mentioned at all positions are corrupted". However, this claim is inaccurate. For example, GRAN [1], a model for hyper-relational knowledge graphs, includes an evaluation setting where all entities mentioned at all positions can be corrupted.

4. **Missing literature**\
The manuscript does not include recent baseline methods, such as HJE [2] (Published on February 13, 2024). HJE demonstrates superior performance compared to the proposed method. For instance, regarding MRR on the WikiPeople dataset, HCNet achieves 0.421, whereas HJE achieves 0.450.

5. **Incorrectly reporting baseline's performance**\
This manuscript incorrectly reports ReAlE's performance [3]. For example, on the FB-AUTO dataset, the original ReAlE paper reports an MRR of 0.873, whereas this manuscript reports it as 0.861.

6. **Misunderstanding on JF17K**\
In the rebuttal, the authors included experiments on the JF17K dataset to compare with baseline methods designed for hyper-relational knowledge graphs. However, the JF17K dataset is an n-ary relational graph dataset, not a hyper-relational knowledge graph dataset in its original form. Thus, the authors should instead conduct experiments on datasets such as WD50K to facilitate a valid comparison with baseline methods targeting hyper-relational knowledge graphs.

[1] Wang et al., 2021. Link Prediction on N-ary Relational Facts: A Graph-based Approach. ACL Findings.\
[2] Li et al., 2024. HJE: Joint Convolutional Representation Learning for Knowledge Hypergraph Completion. TKDE.\
[3] Fatemi et al., 2023. Knowledge Hypergraph Embedding Meets Relational Algebra. JMLR.

Decision: Reject