This paper explores how linear algebra operations in the MATLANG language affect the ability to distinguish between graphs, providing a comprehensive analysis of its expressive power in graph query languages.
Contribution
It characterizes the expressive power of linear algebra-based graph query languages, specifically MATLANG, in differentiating graphs.
Findings
01
Linear algebra operations influence graph distinguishability.
02
Complete characterization of MATLANG's expressive power.
03
Implications for graph query language design.
Abstract
Most graph query languages are rooted in logic. By contrast, in this paper we consider graph query languages rooted in linear algebra. More specifically, we consider MATLANG, a matrix query language recently introduced, in which some basic linear algebra functionality is supported. We investigate the problem of characterising equivalence of graphs, represented by their adjacency matrices, for various fragments of MATLANG. A complete picture is painted of the impact of the linear algebra operations in MATLANG on their ability to distinguish graphs.
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Full text
On the expressive power of linear algebra on graphs
Floris Geerts
University of Antwerp, Antwerp, Belgium
Abstract
There is a long tradition in understanding graphs by investigating their adjacency matrices by means of linear algebra. Similarly, logic-based graph query languages are commonly used to explore graph properties. In this paper, we bridge these two approaches by regarding linear algebra as a graph query language.
More specifically, we consider MATLANG, a matrix query language recently introduced, in which some basic linear algebra functionality is supported. We investigate the problem of characterising the equivalence of graphs, represented by their adjacency matrices, for various fragments of MATLANG. That is, we are interested in understanding when two graphs cannot be distinguished by posing queries in MATLANG on their adjacency matrices.
Surprisingly, a complete picture can be painted of the impact of each of the linear algebra operations supported in MATLANG on their ability to distinguish graphs. Interestingly, these characterisations can often be phrased in terms of spectral and combinatorial properties of graphs.
Furthermore, we also establish links to logical equivalence of graphs. In particular, we show that MATLANG-equivalence of graphs corresponds to equivalence by means of sentences in the three-variable fragment of first-order logic with counting. Equivalence with regards to a smaller MATLANG fragment is shown to correspond to equivalence by means of sentences in the two-variable fragment of this logic.
1 Introduction
Motivated by the importance of linear algebra for machine learning on big data [9, 10, 17, 58, 67] there is a current interest in languages that combine matrix operations with relational query languages in database systems [28, 46, 52, 53, 56]. Such hybrid languages raise many interesting questions from a database theoretical point of view.
The Lara language is one such proposal [46] and its connections to classical database query languages has been recently explored [7].
It seems natural, however, to first consider query languages for matrices alone. These are the focus of this paper.
More precisely, we continue the investigation of the expressive power of the matrix query language MATLANG, recently introduced by Brijder et al. [11, 12], as an analog for matrices of the relational algebra on relations. Intuitively, queries in MATLANG are built up by composing several linear algebra operations commonly found in linear algebra packages. When arbitrary matrices are concerned, it is known that MATLANG is subsumed by aggregate logic with only three non-numerical variables. This implies, among other things, that when evaluated on adjacency matrices of graphs, MATLANG cannot compute the transitive closure of a graph and neither can it express the four-variable query asking if a graph contains a four-clique [11, 12].
In fact, it is implicit in the work by Brijder et al. that when two graphs G and H are indistinguishable by sentences in the three-variable fragment C3 of first-order logic with counting, denoted by G≡C3H, then their adjacency matrices cannot be distinguished by MATLANG expressions that return scalars, henceforth referred to as sentences in MATLANG. The equivalence with respect to such sentences is denoted by G≡MATLANGH. A natural question is whether the converse implication also holds, i.e., does G≡MATLANGH also imply G≡C3H? We answer this question affirmatively.
The underlying proof technique relies on a close connection between C3-equivalence and the indistinguishability of graphs by the 2-dimensional Weisfeiler-Lehman (2WL) algorithm, a result dating back to the seminal paper by Cai, Fürer and Immerman [15, 47]. Indeed, as we will see, the linear algebra operations supported in MATLANG have sufficient power to simulate the 2WL algorithm. Hence, when G≡MATLANGH, then G and H cannot by distinguished by the 2WL algorithm.
This combinatorial interpretation of MATLANG-equivalence immediately provides an insight in which graph properties are preserved under MATLANG-equivalence (see e.g., the work by Fürer [31, 32]). For example, when G≡MATLANGH, then G and H must be co-spectral (that is, their adjacency matrices have the same multi-set of eigenvalues) and have the same number of s-cycles, for s≤6, but not necessarily for s>7. As observed in the conference version of this paper [33], the case of 7-cycles easily follows from the connection with MATLANG. Indeed, the linear algebra expressions for counting s-cycles, for s≤7, given in Noga et al. [1] are expressible in MATLANG and hence, 7-cycles are preserved by 2WL-equivalence. This has recently been verified using other techniques by Arvind et al. [3]. Although formulas exist for counting cycles of length greater than 7 [1], they require counting the number of k-cliques, for k≥4, which is not possible in MATLANG, as observed earlier.
Apart from the logical and spectral/combinatorial characterisation of MATLANG-equivalence, we also point out the correspondence between C3-equivalence (and thus also 2WL-equivalence and MATLANG-equivalence) and conjugacy conditions between adjacency matrices. Roughly speaking, a conjugacy condition refers to a relationship between adjacency matrices of the form AG⋅T=T⋅AH for some matrix T. Here, AG and AH denote the adjacency matrices of G and H, respectively.
As observed by Dawar et al. [25, 26], G≡C3H if and only if there exists a unitary matrix U such that AG⋅U=U⋅AH and moreover, U induces an algebraic isomorphism between the so-called coherent algebras of AG and AH. We recall that a unitary matrix U is a complex matrix whose inverse is its complex conjugate transpose U∗. Coherent algebras and their isomorphisms are detailed later in the paper.
All combined, we have a logical, combinatorial and conjugation-based characterisation of MATLANG-equivalence. Surprisingly, similar characterisations hold also for fragments of MATLANG. We define fragments of MATLANG by allowing only certain linear algebra operations in our expressions. Such fragments are denoted by ML(L), with L the list of allowed operations. The corresponding notion of equivalence of graphs G and H will be denoted by G≡ML(L)H. That is, G≡ML(L)H if any sentence in ML(L) results in the same scalar when evaluated on AG and AH. We investigate equivalence for all sensible MATLANG fragments. Our results are as follows:
For starters, we consider the fragment ML(⋅,tr) that allows for matrix multiplication (⋅) and trace (tr) computation (i.e., taking the sum of the diagonal elements of a matrix). Then, G≡ML(⋅,tr)H if and only if G and H are co-spectral, or equivalently, they have the same number of closed walks of any length, or AG⋅O=O⋅AH for some orthogonal matrix O. We recall that an orthogonal matrix O is a matrix over the real numbers such that its inverse coincides with the transpose matrix Ot (Section 5).
Another small fragment, ML(⋅,∗,1), allows for matrix multiplication, conjugate transposition (∗) and the use of the column vector 1, consisting of all ones. Then, G≡ML(⋅,∗,1)H if and only if G and H are co-main (roughly speaking, they are co-spectral only for special “main” eigenvalues), or equivalently, they have the same number of (not necessarily closed) walks of any length, or AG⋅Q=Q⋅AH for some doubly quasi-stochastic matrix Q. A doubly quasi-stochastic matrix Q is a matrix over the real numbers such that every of its columns and rows sums up to one (Section 6).
When allowing matrix multiplication, tr, ∗, and 1, equivalence of graphs relative to ML(⋅,tr,∗,1) coincides, not surprisingly, to the graphs being both co-spectral and co-main, or equivalently, having the same number of closed walks of any length and the same number of non-closed walks of any length, or such that AG⋅O=O⋅AH, for an orthogonal doubly quasi-stochastic matrix O (Section 6).
More interesting is the fragment ML(⋅,∗,1,diag), which additionally allows for the operation diag(⋅) that turns a column vector into a diagonal matrix with that vector on its diagonal. For this fragment we can tie equivalence to indistinguishability by the 1-dimensional Weisfeiler-Lehman (1WL) algorithm (or colour refinement). This is known to coincide with the graphs having a common equitable partition, or the existence of a doubly stochastic matrix S such that AG⋅S=S⋅AH (a.k.a. as a fractional isomorphism), or C2-equivalence. Here, C2 denotes the two-variable fragment of first-order logic with counting. We recall that a doubly stochastic matrix is a doubly quasi-stochastic matrix whose entries are all non-negative (Section 7).
In the former fragment, replacing the operation diag(⋅) with an operation (⊙v) which pointwise multiplies vectors results in the same distinguishing power. By contrast, the combination of tr and the ability to pointwise multiply vectors results in a stronger notion of equivalence. That is, G≡ML(⋅,tr,∗,1,⊙v)H if and only if G and H are co-spectral and indistinguishable by 1WL. Also in this case, AG⋅O=O⋅AH for an orthogonal matrix O that, in addition, needs to preserve equitable partitions. We define this preservation condition later in the paper (Section 8).
For the larger fragment ML(⋅,tr,∗,1,diag), no elegant combinatorial characterisation is obtained. Nevertheless, for equivalent graphs G and H, AG⋅O=O⋅AH where O is an orthogonal matrix that can be block-structured according to the equitable partitions. This is a stronger notion than the preservation of equitable partitions. Graphs equivalent with respect to this fragment have, for example, the same number of spanning trees. This is not necessarily true for all previous fragments (Section 7).
Finally, as we already mentioned, equivalence relative to MATLANG is shown to correspond to C3-equivalence and 2WL-equivalence. We additionally refine the conjugation-based characterisation given by Dawar et al. [25, 26] so that it compares more easily to the conjugacy notions used for all previous fragments. Furthermore, we show that pointwise multiplication of matrices (the Schur-Hadamard product) is crucial in this setting (Section 9).
Each of these fragments can be extended with addition and scalar multiplication at no increase in distinguishing power. It is also shown when fragments can be extended to accommodate for arbitrary pointwise function applications, on scalars, vectors or matrices. We furthermore exhibit example graphs separating all fragments.
For many of our characterisations we rely on the rich literature on spectral graph theory [14, 19, 20, 21, 35, 42, 65, 72] and the study of the equivalence by the Weisfeiler-Lehman algorithms and fixed-variable fragments of first-order logic with counting [25, 26, 27, 38, 47, 63, 69, 70, 73]. We describe the relevant results in these papers in due course. We also refer to work by Fürer [31, 32] for more examples of connections to graph invariants and to Dawar et al. [25, 26] for connections between logic, combinatorial and spectral invariants.
In some sense, we provide a unifying view of various existing results in the literature by grouping them according to the operations supported in MATLANG. We remark that, recently, another unifying approach has been put forward by Dell et al. [27]. In that work, one considers indistinguishability of graphs in terms of homomorphism vectors. That is, one defines HOMF(G):=(Hom(F,G))F∈F for some class F of graphs, where Hom(F,G) is the number of homomorphisms from F to G. Then G and H are indistinguishable for some class F of graphs when HOMF(G)=HOMF(H). When F consists of all cycles, this notion of equivalence corresponds to ML(⋅,tr)-equivalence (recall the closed walk characterisation of the latter); when F consists of all paths, we have a correspondence with ML(⋅,∗,1)-equivalence (recall the walk characterisation of the latter); when F consists of trees, G and H are equivalent for the 1WL-algorithm and thus also for C2 and ML(⋅,∗,1,diag), and finally, when F consists of all graphs of tree-width at most 2, G and H are equivalent for the 2WL-algorithm and thus also for C3 and MATLANG. Our results can thus be regarded as a re-interpretation of the results in Dell et al. [27] in terms of MATLANG.
We also remark that Ck-equivalence, for k≥4, can be characterised in terms of solutions to linear problems which resemble conjugation-based characterisations [4, 39, 57]. We leave it to future work to identify which additional linear algebra operations to include in MATLANG such that Ck-equivalence can be captured, for k≥4.
Although we made links to logics such as C2 and C3, the connection between MATLANG, rank logics and fixed-point logics with counting, as studied in the context of the descriptive complexity of linear algebra [23, 22, 24, 37, 40, 45], is yet to be explored. Similarly for connections to logic-based graph query languages [2, 6]. We also
mention that MATLANG can be interpreted as a relational query language on so-called K-relations. Such K-relations are standard database relations which are annotated with values from a semiring K [13]. This connection provides an elegant formalism of bridging linear algebra and relational algebra. It further opens the way to explore MATLANG for matrices whose elements are semiring values.
We want to emphasise that in this work we only consider indistinguishability of graphs by means of matrix query languages.
As such, our results do not directly imply which matrix functions
can be computed by MATLANG expressions, in a uniform dimension-independent way.
This is in contrast to the expressiveness results in Brijder et al. [11, 12]. Furthermore, we focus only on undirected graphs in this paper. Such graphs have symmetric adjacency matrices which have many desirable linear algebra properties, diagonalisability being the most important one. Finally, MATLANG is a language in which expressions can combine multiple input matrices. Since our focus is on distinguishing graphs, in this work we restrict MATLANG such that its expressions only take a single matrix, i.e., the adjacency matrix, as input. Some of our results generalise to directed graphs (with asymmetric adjacency matrices) or even arbitrary matrices. This is explored in an upcoming paper [34]. A full treatment of the general setting with multiple inputs is left as future work.
This paper is an extended version of the ICDT 2019 conference paper [33]. It extends that version by including all proofs in detail. Furthermore, the overall presentation and underlying proof techniques have been simplified. In addition, a new section (Section 8) has been added in which the difference between the diag(⋅) and the ⊙v operations is investigated.
2 Background
We denote the set of real numbers by R and the set of complex numbers by C. The set of m×n-matrices over the real (resp., complex) numbers is denoted by Rm×n (resp., Cm×n). Column vectors are elements of Rm×1 (or Cm×1). Row vectors are elements of R1×m (or C1×m). The entries of an m×n-matrix A are denoted by Aij, for i=1,…,m and j=1,…,n. The entries of a (column or row) vector v are denoted by vi, for i=1,…,m. We often identify R1×1 with R, and C1×1 with C and refer to these as scalars. Moreover, the ith row and jth column of a matrix A∈Rm×n (or in Cm×n) are denoted by Ai∗ and A∗j, respectively, for i=1,…,m and j=1,…,n.
The following classes of matrices are of interest in this paper: square matrices (elements in Rn×n or Cn×n), invertible matrices (square matrices A for which there exists an inverse matrix B such that A⋅B=I=B⋅A, where ⋅ denotes matrix multiplication, and I is the identity matrix in Cn×n),
symmetric matrices (such that Aij=Aji for all i and j),
stochastic matrices (Aij∈R, Aij≥0, ∑j=1nAij=1 for all i),
doubly stochastic matrices (Aij∈R, Aij≥0, ∑j=1nAij=1 and ∑i=1mAij=1 for all i and j),
quasi-stochastic matrices (Aij∈R, ∑j=1nAij=1 for all i), doubly quasi-stochastic matrices (Aij∈R, ∑j=1nAij=1 and ∑i=1mAij=1 for all i and j), and orthogonal matrices (invertible real matrices whose inverse matrix is Ot, where Ot denotes the transpose of O obtained by switching rows and columns). The matrix J∈Rn×n denotes the matrix consisting of all ones and Z∈Rn×n denotes the zero matrix. We often do not specify the dimensions of matrices and vectors, as these will be clear from the context.
We consider undirected graphs without self-loops. Let G=(V,E) be such a graph with vertices V={1,…,n} and unordered edges E⊆{{i,j}∣i,j∈V}. The order of G is simply the number of vertices. Then, an adjacency matrix of a graph G of order n, denoted by AG, is an n×n-matrix whose entries (AG)ij are set to 1 if and only if {i,j}∈E, all other entries are set to [math]. Strictly speaking, an adjacency matrix requires an ordering on the vertices in G. In this paper, this ordering is irrelevant and we often speak about “the” adjacency matrix of a graph. For undirected graphs G=(V,E), the adjacency matrix AG is a symmetric binary matrix with zeroes on its diagonal.
An eigenvalue of a matrix A is a scalar λ in C for which there is a non-zero vector v satisfying A⋅v=λv. Such a vector is called an eigenvector of A for eigenvalue λ. The eigenspace of an eigenvalue is the vector space obtained as the span of a maximal set of linear independent eigenvectors for this eigenvalue. Here, the span of a set of vectors just refers to the set of all linear combinations of vectors in that set. A set of vectors is linear independent if no vector in that set can be written as a linear combination of other vectors. The dimension of an eigenspace is the number of linearly independent eigenvectors spanning that space.
The spectrum of an undirected graph can be represented as spec(G)=(λ1m1λ2m2⋯⋯λpmp), where λ1<λ2<⋯<λp are the distinct real eigenvalues of the adjacency matrix AG of G, and where m1,m2,…,mp denote the dimensions of the corresponding eigenspaces. Two graphs are said to be co-spectral if they have the same spectrum.
We use Ck to denote the k-variable fragment of first-order logic with counting. More precisely, formulas in Ck are built up from a binary relation R(x,y) (encoding the edge relation of a graph), disjunction, conjunction, negation and counting quantifiers ∃≥m and use at most k distinct variables [59]. A sentence in Ck is a formula without free variables.
Two graphs G and H are equivalent with regards to Ck, denoted by G≡CkH, if G⊨φ if and only if H⊨φ for every sentence φ in Ck. Here, ⊨ denotes the standard notion of satisfaction of logical formulas (see e.g., [55, 59]).
3 Matrix query languages
As described in Brijder et al. [11], matrix query languages can be formalised as compositions of linear algebra operations. Intuitively, a linear algebra operation takes a number of matrices as input and returns another matrix. Examples of operations are matrix multiplication, conjugate transposition, computing the trace, just to name a few. By closing such operations under composition “matrix query languages” are formed. More specifically, for linear algebra operations op1,…,opk the corresponding matrix query language is denoted by ML(op1,…,opk) and consists of expressions formed by the following grammar:
[TABLE]
where X denotes a matrix variable from an infinite set of variables, which serves to indicate the inputs to expressions, and pi denotes the number of inputs required by operation opi.
As mentioned in the introduction, we focus on the case when only a fixed single matrix variable, denoted by X, is allowed in expressions. We denote expressions by e(X) to make this explicit.
The semantics of an expression e(X) in ML(op1,…,opk) is defined inductively, relative to an assignmentν of X to a matrix ν(X)∈Cm×n, for some dimensions m and n. We denote by e\bigl{(}\nu(X)\bigr{)} the result of evaluating e(X) on ν(X). We define, as expected,
[TABLE]
for linear algebra operation opi.
In this paper we regard MATLANG as the matrix query language built-up from the atomic operations listed in Table 1 and in which only a single matrix variable X is used.
In the table we also show the semantics of the atomic operations. We note that restrictions on the dimensions are in place to ensure that operations are well-defined. Using a simple type system one can formalise a notion of well-formed expressions which guarantees that the semantics of such expressions is well-defined. We refer to Brijder et al. [11] for details. We only consider well-formed expressions from here on.
As one can observe from Table 1, MATLANG is parameterised by a set
Ω of pointwise functions (see the last operation in Table 1). More specifically, Ω=⋃p>0Ωp, where Ωp consists of some functions f:Cp→C. The choice of Ω does not impact our results. Hence, we can take Ω to consist of all possible pointwise functions.
Remark 3.1**.**
The list of operations in Table 1 differs slightly from the list presented in Brijder et al. [11]: We explicitly mention the trace operation (tr) and pointwise function applications for: scalar multiplication (×), addition (+), pointwise product of vectors (⊙v) and pointwise product of matrices, also called the Schur-Hadamard product (⊙). We remark that all of these operations can be expressed in the language proposed in Brijder et al. [11]. Conversely, any single matrix variable expression in the language of Brijder et al. [11] can be expressed in our MATLANG language.
Remark 3.2**.**
The choice of operations included in MATLANG is motivated by operations supported in linear algebra packages such as MAPLE, MATLAB, MATHEMATICA, R, and others [11]. In MATLANG, we only include what we believe to be atomic operations, from which more complex operations can be derived. Many other, more complex, operations could of course be added. Hence MATLANG is just a starting point. We mention that extensions of MATLANG with an inverse operation (taking the inverse of a matrix if it exists) and an eigen operation (returning eigenvalues and eigenvectors) are consider Brijder et al. [11]. The precise impact of these operations on the expressive power is yet to be understood.
In the following, when L is a subset of the operations from
Table 1, we denote by ML(L) the fragment of MATLANG in which only the operations in L are
supported.
4 Expressive power of matrix query languages
As mentioned in the introduction, we are interested in the expressive power of matrix query languages. In analogy with indistinguishability notions used in logic, we consider sentences in our matrix query languages. Let L be a subset of the operations supported in MATLANG. We define an expression e(X) in ML(L) to be a sentence if e(ν(X)) returns a 1×1-matrix (i.e., a scalar) for any assignment ν of the matrix variable X in e(X). We note that the type system of MATLANG allows to easily check whether an expression in ML(L) is a sentence (see Brijder et al. [11] for more details). Having defined sentences, a notion of equivalence naturally follows.
Definition 4.1**.**
Two matrices A and B in Cm×n are said to be ML(L)-equivalent, denoted by A≡ML(L)B, if and only if e(A)=e(B) for all sentences e(X) in ML(L).
In other words, equivalent matrices cannot be distinguished by sentences in the matrix query language fragment under consideration. One could imagine defining equivalence with regards to arbitrary expressions, i.e., expressions in MATLANG that are not necessarily sentences. Such a notion would be too strong, however. Indeed, requiring that e(A)=e(B) for arbitrary expressions e(X) would imply that A=B (just consider e(X):=X)) and then the story ends.
We aim to characterise equivalence of matrices for various matrix query languages. We will, however, not treat this problem in full generality and instead only consider equivalence of adjacency matrices of undirected graphs. The reason for this limitation is two-fold. First, we can benefit from existing results from graph theory; second, undirected graphs have symmetric adjacency matrices and symmetric matrices have desirable linear algebra properties. For example, every symmetric matrix is diagonalisable. We rely on the properties of symmetric matrices in the proofs of our results.
Definition 4.1, when applied to adjacency matrices, naturally results in the following notion of equivalence of graphs.
Definition 4.2**.**
Two graphs G and H of the same order are said to be ML(L)-equivalent, denoted by G≡ML(L)H, if and only if their adjacency matrices are ML(L)-equivalent.
In the following sections we consider equivalence of graphs for various fragments ML(L), starting from simple fragments only supporting a couple of linear algebra operations, up to the full MATLANG matrix query language.
5 Expressive power of the matrix query language ML(⋅,tr)
We start, in Section 5.1, by considering the equivalence of graphs for ML(⋅,tr), i.e., the matrix query language in which only matrix multiplication and the trace operation are supported. We further introduce the notion of conjugacy of matrices, which will be used throughout the paper. In Section 5.2, we then explore which operations can be added to ML(⋅,tr) without increasing its distinguishing power.
5.1 ML(⋅,tr)-equivalence
The matrix query language ML(⋅,tr) is a very restrictive fragment. Indeed, the only sentences that one can formulate in ML(⋅,tr) are of the form (i) #cwalkk(X):=tr(Xk), where Xk stands for the kth power of X, i.e., X multiplied k times with itself, and (ii) products of such sentences. To make the connection to graphs, we recall the following notions. A walk of lengthk in a graph G=(V,E) is a sequence (v0,v1,…,vk) of vertices of G such that consecutive vertices are adjacent in G, i.e., {vi−1,vi}∈E for all i=1,…,k. Furthermore, a closed walk is a walk that starts in and ends at the same vertex. Closed walks of length [math] correspond, as usual, to vertices in G.
We note that, when evaluated on the adjacency matrix AG of G, #cwalkk(AG) is equal to the number of closed walks of length k in G. Indeed, an entry (AGk)vw of the kth power AGk of adjacency matrix AG can be easily seen to correspond to the number of walks from v to w of length k in G. Hence, #cwalkk(AG)=tr(AGk)=∑v∈V(AGk)vv indeed corresponds to the number of closed walks of length k in G.
The following (folklore) characterisations are known to hold.
Proposition 5.1**.**
Let G and H be two graphs of the same order. The following statements are equivalent:
(1)
G* and H have the same number of closed walks of length k, for all k≥0;*
2. (2)
tr(AGk)=tr(AHk)* for all k≥0;*
3. (3)
G* and H are co-spectral; and*
4. (4)
there exists an orthogonal matrix O such that AG⋅O=O⋅AH.
Proof.
For a proof of the equivalences (1) ⇔ (2) ⇔ (3) we refer to Proposition 1 in [25] (although these equivalences appeared in the literature many times before). The equivalence (3) ⇔ (4) is also known (see e.g., Theorem 9-12 in [62]). ∎
Example 5.1**.**
The graphs G1 (
) and H1 (
) are the smallest pair (in terms of number of vertices) of non-isomorphic co-spectral graphs of the same order (see e.g., Figure 6.2 in [18]). From the previous proposition we then know that G1 and H1 have the same number of closed walks of any length. We note that the isolated vertex in G1 ensures that G1 and H1 have the same number of vertices (and thus the same number of closed walks of length [math]). ∎
As anticipated, sentences in ML(⋅,tr) can only extract information from adjacency matrices related to the number of closed walks in graphs. More precisely, we can add to Proposition 5.1 a fifth equivalent condition based on ML(⋅,tr)-equivalence:
Proposition 5.2**.**
For two graphs G and H of the same order, G≡ML(⋅,tr)H if and only if G and H have the same number of closed walks of any length.
Proof.
By definition, if G≡ML(⋅,tr)H, then e(AG)=e(AH) for any sentence e(X) in ML(⋅,tr). This holds in particular for the sentences #cwalkk(X):=tr(Xk) in ML(⋅,tr), for k≥1. Hence, G and H have indeed the same number of closed walks of length k, for k≥1. Furthermore, since G and H are of the same order and AG0=AH0=I (by convention), G and H have also the same number of closed walks of length [math].
For the converse, if G and H have the same number of closed walks of any length, then the previous proposition tells that AG⋅O=O⋅AH for some orthogonal matrix O. We next claim that when AG⋅O=O⋅AH holds for some orthogonal matrix O, then e(AG)=e(AH) for any sentence e(X) in ML(⋅,tr). In fact, this claim will follow from the more general Lemmas 5.1 and 5.2 below. We separate these lemmas from the current proof since we also need them later in the paper.
∎
We note that yet another interpretation of G≡ML(⋅,tr)H can be given in terms of the homomorphism vectors mentioned in the introduction. That is, G≡ML(⋅,tr)H if and only if HOMF(G)=HOMF(H) where F is the set of all cycles [27].
As mentioned in the proof of Proposition 5.2, we still need to show that if AG⋅O=O⋅AH holds for some orthogonal matrix O, then e(AG)=e(AH) for any sentence e(X) in ML(⋅,tr).
In more generality, when AG⋅T=T⋅AH holds for a (not necessarily invertible) matrix T, we say that AG and AH are T-conjugate. We remark that conjugation is not necessarily a symmetric relation, i.e., AG and AH can be T-conjugate whereas AH and AG may not be T-conjugate for the same matrix T.
We also define the notion of T-conjugation for vectors and scalars, as is shown next.
Definition 5.2**.**
Let n>1.
Let T be a matrix in Cn×n.
Two matrices A and B in Cn×n are called T-conjugate if A⋅T=T⋅B. Two column vectors A and B in Cn×1 are T-conjugate if A=T⋅B. Similarly, two row vectors A and B in C1×n are T-conjugate if A⋅T=B. Finally, if A and B are scalars in C (or elements in C1×1), then A and B are T-conjugate if A=B (i.e., T-conjugation of scalars is simply equality).
In ML(⋅,tr) we allow for matrix multiplication and the trace operation. We first show that T-conjugation is preserved by matrix multiplication.
Lemma 5.1**.**
Let ML(L) be any matrix query language fragment and let G and H be two graphs of the same order.
Consider expressions e1(X) and e2(X) in ML(L). If ei(AG) and ei(AH) are T-conjugate, for i=1,2, for some matrix T, then e1(AG)⋅e2(AG) is also T-conjugate to e1(AH)⋅e2(AH) (provided, of course, that the multiplication is well-defined).
sketch.
The proof consists of a simple case analysis depending on the dimensions of e1(AG) and e2(AG) (or equivalently, the dimensions of e1(AH) and e2(AH)) and by using the definition of T-conjugation. We refer for the full proof to the appendix.
∎
When considering the trace operation, we observe that T-conjugation is preserved by the trace operation, provide that T is an invertible matrix.
Lemma 5.2**.**
Let ML(L) be any matrix query language fragment and let G and H be two graphs of the same order. Let e1(X) be an expression in ML(L). If e1(AG) and e1(AH) are T-conjugate for an invertible matrix T,
then tr(e1(AG)) and tr(e1(AH)) are also T-conjugate.
Proof.
Let e(X):=tr(e1(X)). By assumption, e1(AG)⋅T=T⋅e1(AH) for an invertible matrix T in case that e1(AG) is an n×n-matrix with n>1, and e1(AG)=e1(AH) in case that e1(AG) is a sentence. In the latter case, clearly also e(AG)=tr(e1(AG))=tr(e1(AH))=e(AH). In the former case, we use the property that tr(T−1⋅A⋅T)=tr(A) for any matrix A and invertible matrix T (see e.g., Chapter 10 in [5] for a proof of this property). Hence, we have that e(AG)=tr(e1(AG))=tr(T−1⋅e1(AG)⋅T)=tr(T−1⋅T⋅e1(AH))=tr(I⋅e1(AH))=tr(e1(AH))=e(AH) holds, as desired.
∎
We remark that Lemmas 5.1 and 5.2 hold for any fragment ML(L).
The claim at the end of the proof of Proposition 5.2, i.e., that O-conjugation of AG and AH indeed implies that e(AG)=e(AH) for any sentence e(X)∈ML(⋅,tr), now easily follows by induction on the structure of expressions, Indeed, since orthogonal matrices are invertible, Lemmas 5.1 and 5.2 imply that when e1(AG) and e1(AH), and e2(AG) and e2(AH) are O-conjugate for an orthogonal matrix O, then also e1(AG)⋅e2(AG) and e1(AH)⋅e2(AH) are O-conjugate, and tr(e1(AG)) and tr(e1(AH)) are O-conjugate (i.e., equal). Hence, when AG and AH are O-conjugate, e(AG) and e(AH) are O-conjugate for any sentence e(X)∈ML(⋅,tr). That is, e(AG)=e(AH) for any sentence in ML(⋅,tr).
5.2 Adding operations to ML(⋅,tr) without increasing its distinguishing power
We next investigate how much more ML(⋅,tr) can be extended whilst preserving the characterisation given in Proposition 5.2. Some more general observations will be made in this context, which will be used for other fragments later in the paper as well.
First, we consider the extension with scalar multiplication (×) and addition (+).
Lemma 5.3**.**
Let ML(L) be any matrix query language fragment. Let e1(X) and e2(X) be two expressions in ML(L) and consider two graphs G and H of the same order. Then, if e1(AG) and e1(AH), and e2(AG) and e2(AH) are T-conjugate for some matrix T, then also e1(AG)+e2(AG) and e1(AH)+e2(AH) are T-conjugate, and a×e1(AG) and a×e1(AH) are T-conjugate for any scalar a∈C.
Proof.
This is an immediate consequence of the definition of T-conjugation and that matrix multiplication is a bilinear operation, i.e., (a×A+b×B)⋅(c×C+d×D)=(a×c)×(A⋅C)+(a×d)×(A⋅D)+(b×c)×(B⋅C)+(b×d)×(B⋅D), for scalars a, b, c, d∈C and matrices or vectors A,B,C and D.
∎
We next consider complex conjugate transposition (∗).
Lemma 5.4**.**
Let ML(L) be any matrix query language fragment. Let e(X) be an expression in ML(L) and consider two graphs G and H of the same order. Then, if e(AG) and e(AH) are T-conjugate, and e(AH) and e(AG) are T∗-conjugate for some matrix T, then also (e(AG))∗ and (e(AH))∗ are T-conjugate, and (e(AH))∗ and (e(AG))∗ are T∗-conjugate.
Proof.
We distinguish between a number of cases, depending on the dimensions of e(AG) (and hence also of e(AH)). Suppose that e(AG) returns an n×n-matrix for n>1. Then, by assumption e(AG)⋅T=T⋅e(AH) and e(AH)⋅T∗=T∗⋅e(AG). It then follows, using that the operation ∗ is an involution ((A∗)∗=A) and (A⋅B)∗=B∗⋅A∗, that
[TABLE]
and similarly,
[TABLE]
Furthermore, when e(AG) is an n×1-vector for n>1, we have by assumption that e(AG)=T⋅e(AH) and e(AH)=T∗⋅e(AG). Hence,
(e(AG))∗⋅T=(T∗⋅e(AG))∗=(e(AH))∗ and (e(AH))∗⋅T∗=(T⋅e(AH))∗=(e(AG))∗.
Similarly, when e(AG) is a 1×n-vector for n>1, one can verify that ((e(AG))∗=T⋅(e(AH))∗ and (e(AH))∗=T∗⋅(e(AG))∗. Finally, if e(AG) is a sentence then clearly (e(AG))∗=(e(AH))∗.
∎
We next consider pointwise function applications. Later in the paper we show that pointwise function applications on vectors or matrices do add expressive power. This is particularly true for
pointwise multiplication of vectors (⊙v) and of matrices (⊙).
By contrast, when function applications are only allowed on scalars they do not add any expressive power. More specifically, let Ω be an arbitrary set of pointwise functions and let f:Ck→C be a function in Ω. We denote by applys[f](e1,…,ek) the application of f on e1(X),…,ek(X) when each ei(X) is a sentence.
Lemma 5.5**.**
Let ML(L) be any matrix query language fragment. Consider two graphs G and H of the same order and sentences e1(X),e2(X),…,ek(X) in ML(L). Let f:Ck→C be a function in Ω. Suppose that for each i=1,…,k, ei(AG)=ei(AH) (i.e., they are T-conjugate for an arbitrary matrix T). Then also applys[f](e1(AG),…,ek(AG))=applys[f](e1(AH),…,ek(AH)) (i.e., they are T-conjugate as well).
Proof.
This is straightforward to verify since the result of a function f:Ck→C is fully determined by its input values.
∎
Given these lemmas, we can infer that the characterisation given in Proposition 5.2 remains to hold for ML(⋅,tr,+,×,∗,applys[f],f∈Ω)-equivalence.
Corollary 5.3**.**
For two graphs G and H of the same order, we have that G≡ML(⋅,tr)H if and only if G≡ML(⋅,tr,∗,+,×,applys[f],f∈Ω)H. ∎
Proof.
We only need to show that G≡ML(⋅,tr)H implies G≡ML(⋅,tr,∗,+,×,applys[f],f∈Ω)H. By Proposition 5.2, there exists an orthogonal matrix O such that AG⋅O=O⋅AH. Furthermore, we have that O∗⋅AG=(AG⋅O)∗=(O⋅AH)∗=AH⋅O∗ since AG and AH are symmetric real matrices. Hence, AH and AG are O∗-conjugate. We also, importantly, observe that O∗ is an orthogonal matrix as well. Lemmas 5.1 and 5.2 then imply that e(AG) and e(AH) are O-conjugate, and e(AH) and e(AG) are O∗-conjugate for any expression e(X) in ML(⋅,tr). Furthermore, Lemmas 5.3, 5.4 and 5.5 imply that addition, scalar multiplication, complex conjugate transposition and pointwise function applications on scalars preserve O and O∗-conjugation. This in turn implies that e(AG)=e(AH) for any sentence e(X)∈ML(⋅,tr,∗,+,×,applys[f],f∈Ω).
∎
As a consequence, the graphs G1 (
) and H1 (
) from Example 5.1 cannot be distinguished by sentences in ML(⋅,tr,∗,+,×,applys[f],f∈Ω). As we will see later, including any other operation from Table 1, such as 1(⋅), diag(⋅) or pointwise function applications on vectors or matrices, allows us to distinguish G1 and H1.
6 The impact of the 1(⋅) and ∗ operations
We next consider two fragments that support
complex conjugate transposition ∗ and the operation 1(⋅), which returns the all-ones column vector 1111We use 1 to denote the all-ones vector (of appropriate dimension) and use 1(⋅) (with brackets) for the corresponding one-vector operation.. More specifically, we consider the fragments ML(⋅,∗,1) and ML(⋅,tr,∗,1).
The presence of 1(⋅) allows to extract, in combination with ∗, other information from graphs than just the number of closed walks. Indeed, consider the sentence
[TABLE]
in ML(⋅,∗,1) and ML(⋅,tr,∗,1).
When applied on the adjacency matrix AG of a graph G, #walkk(AG)
returns the number of (not necessarily closed) walks in G of length k. In relation to the previous section, co-spectral graphs have the same number of closed walks of any length, yet do not necessarily have the same number of walks of any length. Similarly, graphs with the same number of walks of any length are not necessarily co-spectral. We illustrate this by the following example.
Example 6.1**.**
It can be verified that the co-spectral graphs G1 (
) and H1 (
) of Example 5.1 have 16 versus 20 walks of length 2, respectively. As a consequence, ML(⋅,∗,1) and ML(⋅,tr,∗,1) can distinguish G1 from H1 by means of the sentence #walk2(X).
By contrast, the graphs G2 (
) and H2 (
) are not co-spectral, yet have the same number of walks of any length. It is easy to see that G2 and H2 are not co-spectral (apart from verifying that their spectra are different): H2 has 12 closed walks of length 3 (because of the triangles), whereas G2 has no closed walks of length 3. As a consequence, ML(⋅,tr) (and thus also ML(⋅,tr,∗,1)) can distinguish G2 and H2. We argue below that G2 and H2 have the same number of walks of any length and show that ML(⋅,∗,1) cannot distinguish G2 and H2. ∎
The previous example illustrates the key difference between the fragments ML(⋅,∗,1) and ML(⋅,tr,∗,1). The former can only detect differences in the number of walks of certain lengths, the latter can detect differences in both the number of walks and the number of closed walks of certain lengths.
Graphs sharing the same number of walks of any length have been investigated before in spectral graph theory [19, 20, 21, 42, 65]. To state a spectral characterisation, the so-called main spectrum of a graph needs to be considered. The main spectrum of a graph is the set of eigenvalues whose eigenspace is not orthogonal to the 1 vector. More formally, consider an eigenvalue λ and its corresponding eigenspace, represented by a matrix V whose columns are eigenvectors of λ that span the eigenspace of λ. Then, the main angleβλ of λ’s eigenspace is n1∥Vt⋅1∥2, where ∥⋅∥2 is the Euclidean norm. The main eigenvalues are now simply those eigenvalues with a non-zero main angle. Furthermore, two graphs are said to be co-main if they have the same set of main eigenvalues and corresponding main angles. Intuitively, the importance of the orthogonal projection on 1 stems from the observation that #walkk(AG) can be expressed as ∑iλikβλi2 where the λi’s are the distinct eigenvalues of AG.222Underlying this observation is that AG is a symmetric matrix and hence diagonalisable. Clearly, only those eigenvalues λi for which βλi is non-zero matter when computing #walkk(AG). This results in the following characterisation.
Proposition 6.1** (Theorem 1.3.5 in Cvetković et al. [21]).**
Two graphs G and H of the same order are co-main if and only if they have the same number of walks of length k, for every k≥0. ∎
Furthermore, the following proposition follows implicitly from the proof of Theorem 3 in van Dam et al. [72]. This proposition is also explicitly proved more recently in Theorem 1.2 in Dell et al. [27] in the context of distinguishing graphs by means of homomorphism vectors
HOMF(G) and HOMF(H) where F consists of all paths.
Proposition 6.2**.**
Two graphs G and H of the same order have the same number of walks of length k, for every k≥0, if and only if there is a doubly quasi-stochastic matrix Q such that AG⋅Q=Q⋅AH. ∎
Consider the subgraph G3 (
) of G2 and the subgraph H3 (
) of H2. It is readily verified that there exists a doubly quasi-stochastic matrix Q such that AG3⋅Q=Q⋅AH3. Indeed, AG3⋅Q is equal to
[TABLE]
which is equal to Q⋅AH3. Hence by Proposition 6.2, G3 and H3 have the same number of walks on any length. ∎
Just as for the fragment ML(⋅,tr) (Proposition 5.2), it turns out that sentences in ML(⋅,∗,1) can only extract information from adjacency matrices related to the number of walks in graphs.
More precisely, we have the following proposition.
Proposition 6.3**.**
Let G and H be two graphs of the same order. Then, G≡ML(⋅,∗,1)H if and only if G and H have the same number of walks of any length.
Proof.
It is straightforward to show that G≡ML(⋅,∗,1)H implies that G and H must have the same number of walks of any length. This follows from the same argument as given in the proof of Proposition 5.2. For the converse, we use the characterisation given in Proposition 6.2. That is, if G and H have the same number of walks of any length, then there exists a doubly quasi-stochastic matrix Q such that AG⋅Q=Q⋅AH. In other words, AG and AH are Q-conjugate. We now show that when AG and AH are Q-conjugate, for a doubly quasi-stochastic matrix Q, then e(AG)=e(AH) for all sentences e(X) in ML(⋅,∗,1). We here rely on a more general result (Lemma 6.1 below), which states that T-conjugation is preserved by the operation 1(⋅) provided that T is quasi-stochastic.
We again separate this lemma from the current proof because we need it also later in the paper. This suffices to conclude that expressions in ML(⋅,∗,1) preserve Q-conjugation for a doubly quasi-stochastic matrix Q. Indeed, to deal with complex conjugate transposition, we note that AG⋅Q=Q⋅AH implies that AH⋅Q∗=(Q⋅AH)∗=(AG⋅Q)∗=Q∗⋅AG since AG and AH are symmetric real matrices. Hence, AH and AG are Q∗-conjugate. Furthermore, since Q is a real matrix and quasi doubly-stochastic, also Q∗⋅1=1 holds. That is, Q∗ is a (doubly) quasi-stochastic matrix as well. Hence, Lemmas 5.1 and 6.1 imply that Q-conjugation and Q∗-conjugation are preserved by matrix multiplication and the one-vector operation. Combined with Lemma 5.4, we may conclude that Q-conjugation and Q∗-conjugation is also preserved by complex conjugate transposition. Hence, by induction on the structure of expressions, e(AG)=e(AH) for any sentence e(X)∈ML(⋅,∗,1).
∎
We now show that T-conjugation is preserved under the one-vector operation for any quasi-stochastic matrix T. In fact, since the result of 1(⋅) is only dependent on the dimensions of the input, we have do not even need the T-conjugation assumption on the inputs.
Lemma 6.1**.**
Let ML(L) be any matrix query language fragment and consider two graphs G and H of the same order. Let e1(X) be an expression in ML(L). Then, 1(e1(AG)) and 1(e1(AH)) are T-conjugate for any quasi-stochastic matrix T.
Proof.
The proof is straightforward. Let e(X):=1(e1(X)). We distinguish between the following cases, depending on the dimensions of e1(AG). If e1(AG) is an n×n-matrix or n×1-vector, for n>1, then e(AG)=e(AH)=1 and e(AG)=1=T⋅1=T⋅e(AH). Furthermore, if e1(AG) is a 1×n-vector or sentence, then e(AG)=e(AH)=1 and thus these agree and are T-conjugate.
∎
We next turn our attention to ML(⋅,tr,∗,1). We know from Propositions 5.1 and 5.2 that G≡ML(⋅,tr,∗,1)H implies that G and H are co-spectral. Combined with Proposition 6.1 and the fact that the sentence #walkk(X) counts the number of walks of length k, we have that G≡ML(⋅,tr,∗,1)H implies that G and H are co-spectral and co-main. The following is known about such graphs.
Proposition 6.4** (Corollary to Theorem 2 in Johnson and Newman [49]).**
Two co-spectral graphs G and H of the same order are co-main if and only if there exists a doubly quasi-stochastic orthogonal matrix O such that AG⋅O=O⋅AH. ∎
In other words, G≡ML(⋅,tr,∗,1)H implies the existence of a doubly quasi-stochastic orthogonal matrix O such that AG⋅O=O⋅AH. We further observe that AH⋅O∗=O∗⋅AG and that O∗ is a doubly quasi-stochastic orthogonal matrix as well.
We can now use Lemmas 5.1, 5.2 and 6.1 to show the converse. Indeed, these lemmas combined tell us that AG⋅O=O⋅AH implies that e(AG)=e(AH) for any sentence e(X) in ML(⋅,tr,∗,1). As a consequence, we have the following proposition.
Proposition 6.5**.**
For two graphs G and H of the same order, G≡ML(⋅,tr,∗,1)H if and only if G and H have the same number of closed walks of any length, and the same number of walks of any length, if and only if AG⋅O=O⋅AH for a doubly quasi-stochastic orthogonal matrix O. ∎
We can also phrase ML(⋅,tr,∗,1)-equivalence in terms of homomorphism vectors. That is,
G≡ML(⋅,tr,∗,1)H if and only if HOMF(G)=HOMF(H), where F now consists of all cycles and paths. This complements the results in Dell et al. [27].
As a note aside, an alternative characterisation to Proposition 6.4 (Theorem 3 in van Dam et al. [72]) is that G and H are co-spectral and co-main if and only if both G and Hand their complement graphs Gˉ and Hˉ are co-spectral. Here, the complement graph Gˉ of G is the graph with adjacency matrix given by J−AG−I, and similarly for Hˉ.
Consider the subgraph G4 (
) of G2 and the subgraph H4 (
) of H2. These are known to be the smallest non-isomorphic co-spectral graphs with co-spectral complements (see e.g., Figure 4 in [41]). From the previous remark it follows that G4 and H4 have the same number of walks of any length and the same number of closed walks of any length. These graphs are thus indistinguishable by sentences in ML(⋅,∗,1) and ML(⋅,tr,∗,1). Combined with our observation in Example 6.2 that also G3 and H3 have the same number of walks, we conclude that the disjoint unions G2=G3∪G4 (
) and H2=H3∪H4 (
) have the same number of walks of any length, as anticipated in Example 6.1. ∎
Clearly,
G≡ML(⋅,tr,∗,1)H implies G≡ML(⋅,∗,1)H. We already mentioned in Example 6.1 that the graphs G2 (
) and H2 (
) show that the converse does not hold.
We conclude again by observing that addition, scalar multiplication and pointwise function application on scalars can be added to ML(⋅,∗,1) and ML(⋅,tr,∗,1) at no increase in expressiveness.
Corollary 6.4**.**
Let G and H be two graphs of the same order. Then,
(1)
G≡ML(⋅,∗,1,+,×,applys[f],f∈Ω)H* if and only if G≡ML(⋅,∗,1)H; and*
2. (2)
G≡ML(⋅,tr,∗,1,+,×,applys[f],f∈Ω)H* if and only if G≡ML(⋅,tr,∗,1)H.*
Proof.
(1) We only need to show that G≡ML(⋅,∗,1)H implies G≡ML(⋅,∗,1,+,×,applys[f],f∈Ω)H. We have that G≡ML(⋅,∗,1)H implies AG⋅Q=Q⋅AH for a doubly quasi-stochastic matrix Q (Proposition 6.3). Furthermore, in the proof of Proposition 6.3 we have shown that AH⋅Q∗=Q∗⋅AG where Q∗ is again a doubly quasi-stochastic matrix. Lemmas 5.1, 5.3, 5.4, 5.5 and 6.1 imply that Q-conjugation and Q∗-conjugation are preserved by all operations in the fragment ML(⋅,∗,1,+,×,applys[f],f∈Ω).
(2) We only need to show that G≡ML(⋅,tr,∗,1)H implies G≡ML(⋅,tr,∗,1,+,×,applys[f],f∈Ω)H. We have that G≡ML(⋅,tr,∗,1)H implies AG⋅O=O⋅AH for a doubly quasi-stochastic orthogonal matrix O (Proposition 6.5). We observed earlier that AH⋅O∗=O∗⋅AG and that O∗ is a doubly quasi-stochastic orthogonal matrix as well. Lemmas 5.1, 5.2, 5.3, 5.4, 5.5 and 6.1, imply that O-conjugation and O∗-conjugation are preserved by all operations in the fragment ML(⋅,∗,tr,1,+,×,applys[f],f∈Ω).
In both cases, we can therefore conclude, by induction on the structure of expressions, that for any sentence e(X), e(AG) and e(AH) are conjugate and hence, e(AG)=e(AH).
∎
As we will see later, including any other operation from Table 1, such as diag(⋅) or pointwise function applications on vectors or matrices, allows us to distinguish G4 and H4. We recall from Example 6.3 that these graphs cannot be distinguished by sentences in ML(⋅,∗,1) and ML(⋅,tr,∗,1).
7 The impact of the diag(⋅) operation
We next consider the operation diag(⋅) which takes as a column vector as input and returns the diagonal matrix with the input vector on its diagonal.
333The diag(⋅) operation is also defined for 1×1-matrices (scalars) in which case it just returns that scalar.
From the fragments considered so far,
ML(⋅,∗,1) and ML(⋅,tr,∗,1) are the only fragments in which vectors can be defined and for which the inclusion of diag(⋅) has an impact.
Therefore, in this section we consider equivalence with regards to ML(⋅,∗,1,diag) and ML(⋅,tr,∗,1,diag). This section is organised as follows. First, we illustrate what information can be obtained from graphs using the
diag(⋅) operation (Section 7.1). We then show in Section 7.2 that one can compute so-called equitable partitions of graphs. From this, we can infer that equivalence of graphs with regards to the fragments under consideration implies
that the graphs have a common equitable partition. We use this observation in Sections 7.3 and 7.4 to characterise ML(⋅,∗,1)- and ML(⋅,tr,∗,1)-equivalence, respectively.
Finally, in Section 7.5 we show that we can add pointwise function applications on vectors without increasing the distinguishing power of the fragments.
7.1 Example of the impact of the presence of diag(⋅)
Using diag(⋅) we can extract new information from graphs, as is illustrated in the following example.
Example 7.1**.**
Consider graphs G4 (
) and H4 (
). In G4 we have vertices of degrees [math] and 2, and in H4 we have vertices of degrees 1, 2 and 3. We will count the number of vertices of degree 3. Given that we know that 3 is an upper bound on the degrees of vertices in G4 and H4, we consider the sentence #3degr(X) given by
[TABLE]
in which we, for convenience, allow addition and scalar multiplications. Each of the subexpressions diag(X⋅1(X)−d×1(X)), for d=0,1 and 2, sets the diagonal entry corresponding to vertex v to [math] when v has degree d. By taking the product of these diagonal matrices, entries that are set to [math] will remain zero in the resulting diagonal matrix. This implies that, after taking these products, the only non-zero diagonal entries are those corresponding to vertices of degree different from [math], 1 or 2. In other words, only for vertices of degree 3 the diagonal entries carry a non-zero value, i.e., the value 6=(3−0)(3−1)(3−2). By appropriately rescaling by the factor 61, the diagonal entries for the degree three vertices are set to 1, and then summed up. Hence, #3degr(X) indeed counts the number vertices of degree three when evaluated on adjacency matrices of graphs with vertices of maximal degree 3. Since #3degr(AG4)=[0]=[1]=#3degr(AH4) we can distinguish G4 and H4. We can obtain similar expressions for #ddegr(X) for arbitrary d, provided that we know the maximal degree of vertices in the graph. The way that these expressions are constructed is similar to the so-called Schur-Wielandt Principle indicating how to extract entries from a matrix that hold specific values by means of pointwise multiplication of matrices (see e.g., Proposition 1.4 in [61]). Here, we do not have pointwise matrix multiplication available but since we extract information from vectors, pointwise multiplication of vectors is simulated by normal matrix multiplication of diagonal matrices with the vectors on their diagonals. ∎
The use of the diagonal matrices and their products as in our example sentence #3degr(X) can also be generalised to obtain information about so-called iterated degrees of vertices in graphs, e.g., to identify and/or count vertices that have a number of neighbours each of which have neighbours of specific degrees, and so on. Such iterated degree information is closely related to equitable partitions and fractional isomorphisms of graphs (see e.g., Chapter 6 in [66]). We phrase our results in terms of equitable partitions instead of iterated degree sequences.
7.2 Equitable partitions
Formally, an equitable partitionV={V1,…,Vℓ} of G is a partition of the vertex set V of G such that for all i,j=1,…,ℓ and v,v′∈Vi, deg(v,Vj)=deg(v′,Vj). Here, deg(v,Vj) is the number of vertices in Vj that are adjacent to v. In other words, an equitable partition is such that the graph is regular within each part, i.e., all vertices in a part have the same degree, and is bi-regular between any two different parts, i.e., the number of edges between any two vertices in two different parts is constant. A graph always has a trivial equitable partition: simply treat each vertex as a part by its own. More interesting is the coarsest equitable partition of a graph, i.e., the unique equitable partition for which any other equitable partition of the graph is a refinement thereof [66].
The conditions underlying equitable partitions can be equivalently stated in terms of adjacency matrices and indicator vectors describing the partitions. We first introduce the notion of indicator vector.
Let G=(V,E) be a graph of order n with V={1,…,n}.
Let V′⊆V. We denote the indicator vector of V′ as the column vector 1V′ in Rn×1 and defined such that (1V′)v=1 if v∈V′ and (1V′)v=0 otherwise. Then, given a partition V={V1,…,Vℓ} of V we represent V by the ℓ indicator vectors 1Vi,…,1Vℓ.
We observe that 1=∑i=1ℓ1Vi due to V being a partition. We can now express that
V is an equitable partition in linear algebra terms. More precisely, V is an equitable partition of G if and only if for all i,j=1,…,ℓ,
[TABLE]
for some (arbitrary) vertex v∈Vi.
We next use the standard terminology for relating two graphs in terms of their equitable partitions [66]. More specifically, two graphs G and H are said to have a common equitable partition if there exists an equitable partition V={V1,…,Vℓ} of G and an equitable partition W={W1,…,Wℓ} of H such that (a) the sizes of the parts agree, i.e., ∣Vi∣=∣Wi∣ for each i=1,…,ℓ, and (b) deg(v,Vj)=deg(w,Wj) for any v∈Vi and w∈Wi and any i,j=1,…,ℓ. When V and W
satisfy these conditions, we say that these partitions witness that G and H have a common equitable partition.
Similarly, two graphs are said to have a common coarsest equitable partition if the partitions V of G and W of H mentioned above are the coarsest equitable partitions of G and H, respectively.
Proposition 7.1 below characterises when two graphs do have a common equitable partition. Furthermore, when two graphs have a common equitable partition they also have a common coarsest equitable partition (see e.g., Theorem 6.5.1 in [66]).
Equitable partitions naturally arise as the result of the colour refinement procedure [8, 38, 73], also known as the 1-dimensional Weisfeiler-Lehman (1WL) algorithm, used as a subroutine in graph isomorphism solvers. Furthermore, there is a close connection to the study of fractional isomorphisms of graphs [66, 69], as already mentioned in the introduction. We recall: two graphs G and H are said to be fractional isomorphic if there exists a doubly stochastic matrix S such that AG⋅S=S⋅AH. Furthermore, a logical characterisation of graphs with a common equitable partition exists, as is stated next.
Proposition 7.1** (Theorem 1 in Tinhofer [69], Section 4.8 in Immerman and Lander [47]).**
Let G and H be two graphs of the same order. Then, G and H are fractional isomorphic if and only if G and H have a common equitable partition if and only if G≡C2H. ∎
Example 7.2**.**
The matrix linking the adjacency matrices of G3 (
) and H3 (
) in Example 6.2 is in fact a doubly stochastic matrix (all its entries are either [math] or 21). Hence, G3 and H3 have a common equitable partition by Proposition 7.1.
One can alternatively verify that the partitions of G3 and H3
consisting of a single part containing all the vertices of G3 and H3, respectively, witness that G3 and H3 have a common equitable partition.
By contrast, graphs G2 (
) and H2 (
) do not have a common equitable partition. Indeed, fractional isomorphic graphs must have the same multi-set of degrees, i.e., the same multi-set consisting of the degrees of vertices (Proposition 6.2.6 in [66]), which does not hold for G2 and H2. Indeed, we note that there is an isolated vertex in G2 but not in H2. For the same reason, G1 (
) and H1 (
), and G4 (
) and H4 (
) are not fractional isomorphic. ∎
To relate equitable partitions to ML(⋅,∗,1,diag)- and ML(⋅,tr,∗,1,diag)-equivalence, we show that the presence of diag(⋅) allows us to formulate a number of expressions, denoted by eqparti(X), for i=1,…,ℓ, that together extract the coarsest equitable partition from a given graph. By evaluating these expressions on AG and AH, one can use additional sentences to detect whether these partitions witness that G and H have a common equitable partition. In this subsection, L can be either {⋅,∗,1,diag} or {⋅,tr,∗,1,diag}.
Proposition 7.2**.**
Let G and H be two graphs of the same order. Then, G≡ML(L)H implies that G and H have a common equitable partition.
Proof.
The proof is quite lengthy so we first describe its structure.
(a)
We first argue that we can use addition and scalar multiplication at no increase in distinguishing power. This will simplify the construction of the expressions later on. We denote by L+ the extension of L with + and ×.
(b)
We then show how to construct a number of expressions, denoted by eqparti(X), for i=1,…,ℓ, in ML(L+). The key property of these expressions is that when they are evaluated on the adjacency matrix AG of G,
eqparti(AG), for i=1,…,ℓ, correspond to indicator vectors representing an equitable partition of G.
(c)
The construction of the expressions eqparti(X), for i=1,…,ℓ, depend on AG. As such, it is not guaranteed that eqparti(AH), for i=1,…,ℓ, correspond to indicator vectors representing an equitable partition of H. We show, however, that when G≡ML(L+)H holds, then eqparti(AH), for i=1,…,ℓ, indeed correspond to indicator vectors representing an equitable partition of H. To show this, we construct a number of sentences in ML(L+).
(d)
Finally, we observe that the partitions represented by
eqparti(AG) and eqparti(AH), for i=1,…,ℓ, witness that G and H have a common equitable partition.
Hence, all combined, this suffices to conclude that G≡ML(L+)H implies that G and H have a common equitable partition. Given (a), the same conclusion holds for G≡ML(L)H.
(a) Showing that G≡ML(L)H if and only if G≡ML(L+)H.
As mentioned earlier, it will be convenient to use addition and scalar multiplication
in our expressions. Clearly, G≡ML(L+)H implies G≡ML(L)H. Hence, it suffices to show that G≡ML(L)H implies G≡ML(L+)H.444We remark that we cannot rely yet on the conjugation-preservation Lemma 5.3 to show that G≡ML(L+)H if and only if G≡ML(L)H. Indeed, at this point we do not know yet for what kind of matrices T, T-conjugation is preserved by the diag(⋅)-operation. This will only be settled in Lemma 7.1 later in this section.
To see this, we observe that any expression in ML(L+)
can be written as a linear combination of expressions in ML(L). For completeness, we verify this in the appendix.
Consider now a sentence e(X) in ML(L+).
Hence, e(X) can be written as ∑i=1pai×ei(X)
with ai∈C and sentences ei(X)∈ML(L), for i=1,…,p. By assumption, ei(AG)=ei(AH), for i=1,…,p, Hence also e(AG)=∑i=1pai×ei(AG)=∑i=1pai×ei(AH)=e(AH).
As a consequence, G≡ML(L)H indeed implies G≡ML(L+)H.
(b) Computing the coarsest equitable partition of G by expression in ML(L+).
We next show that we can compute the indicator vectors of an equitable partition of G by means of expressions in ML(L+). To see this, we implement the algorithm GDCR for finding this partition [51]. We recall this algorithm (in a slightly different form than presented in Kersting et al. [51]) in Algorithm 1. In a nutshell, the algorithm takes as input AG, the adjacency matrix of G, and returns a matrix whose columns hold indicator vectors that represent an equitable partition of G.
The algorithm starts, on line 1, by creating a partition consisting of a single part containing all vertices, represented by the indicator vector 1, and stored in vector B(0). Then, in the ith step, the current partition is represented by ℓi−1 indicator vectors 1V1(i−1),…,1Vℓi−1(i−1) which constitute the columns of matrix B(i−1). The refinement of this partition is then computed in two steps. First, the matrix M(i):=AG⋅B(i−1) (line 4) is computed; second, each 1Vj(i−1) is refined by putting vertices v and w in the same part if and only if they have the same rows in M(i), i.e., when Mv∗(i)=Mw∗(i) holds (line 5). The corresponding partition V(i) is then represented by, say ℓi, indicator vectors and stored as the columns of B(i) (line 6). This is repeated until no further refinement of the partition is obtained. At most n iterations are needed. The correctness of the algorithm is established in [51]. That is, the resulting indicator vectors represent an equitable partition of G. In fact, they represent the coarsest equitable partition of G.
We next detail how a run of the algorithm on adjacency matrix AG can be simulated using expressions in ML(L+). The initialisation step is easy: We compute B(0) by means of the expression b(0)(X):=1(X). Clearly, B(0)=b(0)(AG). Next, suppose by induction that we have ℓi−1 expressions b1(i−1)(X),…,bℓi−1(i−1)(X) such that when these expressions are evaluated on AG, they return the indicator vectors stored in the columns of B(i−1). That is, 1Vj(i−1)=bj(i−1)(AG) for all j=1,…,ℓi−1. We next show how the ith iteration is simulated.
We first compute the ℓi−1 vectors stored in the columns of M(i) (line 4). We compute these column vectors one at a time. To this aim, we consider expressions
[TABLE]
Clearly, mj(i)(AG)=M∗j(i), as desired.
A bit more challenging is the computation of the refined partition in V(i) (line 5) since we need to inspect all columns M∗j(i) and identify rows on which all these columns agree, as explained above. It is here that the diag(⋅) operation plays a crucial role. Moreover, to compute this refined partition we need to know all values occurring in M(i). The expressions below depend on these values and hence on the input adjacency matrix AG.
Let Dj(i) be the set of values occurring in the column vector M∗j(i), for j=1,…,ℓi−1. We compute, by means of an ML(L+) expression, an indicator vector which identifies the rows in M∗j(i) that hold a specific value c∈Dj(i). This expression is similar to the one used in Example 7.1 to extract vertices of degree 3 from the degree vector. More precisely, we consider expressions
[TABLE]
for the current iteration i, column j in M(i), and value c∈Dj(i). The correctness of these expressions follows from a similar explanation as given in Example 7.1. Given these expressions, one can now easily obtain an indicator vector identifying all rows in M(i) that hold a specific value combination (c1,…,cℓi−1) in their columns, where each cj∈Dj(i), as follows:
[TABLE]
That is, we simply take the boolean conjunction of all indicator vectors 1=cj(i),j(X), for j=1,…,ℓi−1. We note that 1=(c1,…,cℓi−1)(i)(AG) may return the zero vector, i.e., when (c1,…,cℓi−1) does not occur as a row in M(i).
We are only interested in value combinations that do occur. Suppose that there are ℓi distinct value combinations (c1,…,cℓi−1) for which 1=(c1,…,cℓi−1)(i)(AG) returns a non-zero indicator vector. We denote by b1(i)(X),…,bℓi(i)(X) the corresponding expressions of the form 1=(c1,…,cℓi−1)(i)(X). It should be clear that b1(i)(AG),…,bℓi(i)(AG) are indicator vectors corresponding to the refined partition V(i) as stored in B(i). This concludes the simulation of the ith iteration of the algorithm.
Finally, after the nth iteration we define
[TABLE]
for i=1,…,ℓn. In the following, we denote ℓn by ℓ. We remark once more that all expressions defined above depend on the input AG, as their definitions rely on the values occurring in the matrices M(i) computed along the way.
(c) Checking that G≡ML(L+)H implies that
eqparti(AH), for i=1,…,ℓ, also represent an equitable partition of H. Recall that we want to show that if G≡ML(L+)H holds, then G and H have a common equitable partition. As a first step we verify that
G≡ML(L+)H implies that the vectors eqparti(AH), for i=1,…,ℓ, correspond to an equitable partition of H.
The challenge is to check all this by means of sentences in ML(L+).
We will use the following sentences.
For each i=1,…,ℓ, we first check whether eqparti(AH) is also a binary vector.
We note that, by construction of the expression eqparti(X), eqparti(AH) returns a real vector. To check whether every entry in eqparti(AH) is either [math] or 1, we show that all of its entries must satisfy the equation x(x−1)=0. To this aim, we consider the ML(L+) sentence
[TABLE]
We claim that if X is assigned a diagonal real matrix, say Δ, then binary_diag(Δ)=[0] if and only if Δ is a binary diagonal matrix.
Indeed, if Δ is a binary diagonal matrix, then Δ⋅Δ=Δ, Δ⋅Δ−Δ=Z, where Z is the zero matrix, and hence binary_diag(Δ)=1t⋅Z⋅Z⋅1=[0]. Conversely, suppose that binary_diag(Δ)=[0]. We observe that (Δ⋅Δ−Δ)⋅(Δ⋅Δ−Δ) is a diagonal matrix with squared real numbers on its diagonal. Hence, binary_diag(Δ)=[0] implies that the sum of the (squared real) diagonal elements in Δ⋅Δ−Δ is [math]. This in turn implies that every element on the diagonal in Δ⋅Δ−Δ must be zero. Hence, every element on Δ’s diagonal must satisfy the equation x2−x=0, implying that either x=0 or x=1. As a consequence, Δ is a binary diagonal matrix.
We now observe that binary_diag(diag(eqparti(AG)))=[0] since eqparti(AG) returns an indicator vector. Then, G≡ML(L+)H implies that the equality
[TABLE]
must hold, for all i=1,…,ℓ. Hence, the matrices diag(eqparti(AH)) are indeed binary and so are its diagonal elements described by eqparti(AH), as desired.
2. 2.
We next verify that all indicator vectors eqparti(AH) combined represent a partition of the vertex set of H. To verify this partition condition,
we simply consider the sentence \mathbb{1}(X)^{*}\mskip 2.0mu{\cdot}\mskip 2.0mu\bigl{(}\sum_{i=1}^{\ell}\mathsf{equit}_{i}(X)\bigr{)}. Since G≡ML(L+)H implies
[TABLE]
it must be the case that the indicator vectors eqparti(AH), for i=1,…,ℓ, form a partition.
3. 3.
We finally verify that the partition of H represented by the indicator vectors equiti(AH), for i=1,…,ℓ, is an equitable partition of H. Let V={V1,…,Vℓ} be the equitable partition of G, represented by the indicator vectors eqparti(AG), for i=1,…,ℓ. Similarly, let
W={W1,…,Wℓ} be the partition of H, represented by the indicator vectors eqparti(AH), for i=1,…,ℓ. We show that W is an equitable partition of H.
As already mentioned at the beginning of this section, we can rephrase “being equitable” in linear algebra terms. In particular, we know that for any i,j=1,…,ℓ,
[TABLE]
returns the zero vector, where v is an arbitrary vertex in Vi, the part corresponding to the indicator vector eqparti(AG). We want to check whether the same condition holds for AH. We therefore consider the expressions equi_testij(X), for i,j=1,…,ℓ given by
[TABLE]
and check whether, when evaluated on AH, the obtained diagonal matrix is the zero matrix. This would imply that for all i,j=1,…,ℓ,
[TABLE]
also returns the zero vector. As a consequence, W is an equitable partition of H. It rests us only to show that we can check, by means of sentences, whether a diagonal matrix is the zero matrix. We use the sentence
[TABLE]
for this purpose. A similar argument as for the expression binary_diag(X) shows that the zerotest_diag(X) expression returns [0] on diagonal real matrices if and only if the diagonal matrix is the zero matrix. We here again use that a sum of squares equals zero if and only if each summand is zero. Since G≡ML(L+)H, we have that
[TABLE]
for all i,j=1,…,ℓ, as desired.
(d) Verifying that G and H have a common equitable partition. To conclude the proof we need to show that the equitable partitions V of G
and W of H, as defined above, witness that G and H have a common equitable partition. In other words, we must have that (i) ∣Vi∣=∣Wi∣ for every i=1,…,ℓ; and
(ii) for any i,j=1,…,ℓ, deg(v,Vj)=deg(w,Wj) for any v∈Vi and any w∈Wi. We observe that the expressions equi_testij(X) used above already verify condition (ii). We next show that, for each i=1,…,ℓ, the indicator vector equiti(AG)
contains the same number of 1’s as eqparti(AG).
To show this, it suffices to consider the sentences (1(X))∗⋅eqparti(X), for i=1,…,ℓ. Clearly, G≡ML(L+)H implies that 1∗⋅eqparti(AG)=1∗⋅eqparti(AH), for i=1,…,ℓ. Hence, eqparti(AH) and eqparti(AG) contain the same number of ones. So, we may conclude that G≡ML(L+)H implies indeed that G and H have a common equitable partition. Given that
G≡ML(L+)H if and only if G≡ML(L)H, also
G≡ML(L)H implies that G and H have a common equitable partition, as desired. ∎
7.3 Characterisation of ML(⋅,∗,1,diag)-equivalence
We next consider ML(⋅,∗,1,diag)-equivalence. We have just shown that ML(⋅,∗,1,diag)-equivalent graphs have a common equitable partition. The converse also holds, as will be shown below (Proposition 7.3).
We first introduce a notion of compatibility that will be used to define the proper notion of conjugation for ML(⋅,∗,1,diag)-equivalence.
Let G and H be two graphs of order n.
Let V={V1,…,Vℓ} and W={W1,…,Wℓ} be partitions of G and H, respectively.
Furthermore, let 1Vi and 1Wi, for i=1,…,ℓ, denote the indicator vectors corresponding to Vi∈V and Wi∈W, respectively. Consider a matrix T in Cn×n. Then, T is said to be compatible with the partitions V of G and W of H, if for i=1,…,ℓ,
[TABLE]
Intuitively, this condition implies that T has a block structure determined by the partitions V and W and only has non-zero blocks for blocks corresponding to the same parts Vi and Wi in these partitions.
Proposition 7.3**.**
Let G and H be two graphs of the same order. If G and H have a common equitable partition, then e(AG)=e(AH) for every sentence e(X) in ML(⋅,∗,1,diag).
Proof.
By assumption, G and H have a common equitable partition.
Let V={V1,…,Vℓ} and W={W1,…,Wℓ} be partitions of G and H, respectively, that witness this fact.
As before, we denote by 1Vi and 1Wi, for i=1,…,ℓ, the corresponding indicator vectors. We know from Proposition 7.1 that there exists a doubly stochastic matrix S such that AG⋅S=S⋅AH. As previously observed, also AH⋅S∗=S∗⋅AG holds, where S∗ is again doubly stochastic. Then, Lemmas 5.1, 5.4 and 6.1 imply that S-conjugation and S∗-conjugation are preserved by matrix multiplication, complex conjugate transposition, and the one-vector operation. To conclude that G≡ML(⋅,∗,1,diag)H holds, we verify that the diag(⋅) operation also preserves S- and S∗-conjugation. We rely on a more general result (Lemma 7.1 below), which states that T-conjugation, for a matrix T, is preserved by the diag(⋅) operation provided that T is doubly quasi-stochastic and compatible with equitable partitions of G and H that witness that G and H have a common equitable partition. We again separate this lemma from the current proof because we need it later in the paper.
When considering the doubly stochastic matrix S such that AG⋅S=S⋅AH holds, the matrix S can be assumed to be compatible with V and W. To see this, we recall from the proof of Theorem 6.5.1 in [66] that we can take S to be such that for i=j, diag(1Vi)⋅S⋅diag(1Wj) is the ∣Vi∣×∣Wj∣ zero matrix, and for i=j, diag(1Vi)⋅S⋅diag(1Wi) is the square ∣Vi∣×∣Wi∣ matrix in which all entries are equal to ∣Vi∣1. Hence,
diag(1Vi)⋅S=S⋅diag(1Wi) for all i,j=1,…,ℓ.
As a consequence, if e1(AG) and e1(AH) are S-conjugate, then Lemma 7.1 implies that diag(e1(AG)) and diag(e1(AH)) are S-conjugate. We also note that diag(1Wi)⋅S∗=S∗⋅diag(1Vi). So, S∗ is compatible with W and V. An inductive argument then shows that e(AG) and e(AH) are S-conjugate (and thus equal) for any sentence e(X) in ML(⋅,∗,1,diag), as desired.
∎
Let V and W be equitable partitions of G and H, respectively, that witness that G and H have a common equitable partition.
We next show that T-conjugation, by means of doubly quasi-stochastic matrices T that are compatible with V and W,
is indeed preserved by the diag(⋅) operation. Showing this requires a bit more work than our previous conjugation-preservation results.
More precisely, a key property underlying this preservation property is the following: Any vector that can be obtained by evaluating expressions in ML(⋅,∗,1,diag) on an adjacency matrix of a graph, can be written in a canonical way in terms of the indicator vectors representing an equitable partitions of that graph. We state this requirement for general matrix query languages, as follows.
Let ML(L) be a matrix query language.
We say that ML(L)-vectors are constant on equitable partitions if, for any expression e(X)∈ML(L), any graph G, and
any equitable partition V={V1,…,Vℓ} of G,
when e(AG) is an n×1-vector then there exists scalars ai∈C, for i=1,…,ℓ,
such that
[TABLE]
holds. Here, 1V1,…,1Vℓ represent the equitable partition V of G.
Intuitively, this condition is important for the diag(⋅) operation since it takes a vector as input and the linear combination (1) allows one to only reason about (linear combinations of) diagonal matrices obtained by the indicator vectors of the equitable partitions. Compatibility in turn implies conjugation preservation for such (indicator vector-based) diagonal matrices, which can then be lifted, due to linearity, to conjugation of arbitrary diagonal matrices. We make this argument more formal in the proof of the following Lemma.
Lemma 7.1**.**
Let ML(L) be a matrix query language fragment such that ML(L)-vectors are constant on equitable partitions.
Let G and H be two graphs of the same order which have a common equitable partition.
Furthermore, let V and W be equitable partitions of G and H, respectively, that witness that G and H have a common equitable partition, and let T be a doubly quasi-stochastic matrix which is compatible with V and W.
Finally, let e(X) be an expression in ML(L). Then, if e(AG) and e(AH) are T-conjugate, then also diag(e(AG)) and diag(e(AH)) are T-conjugate.
Proof.
Let e(X) be an expression in ML(L). Consider now e′(X):=diag(e(X)). We distinguish between two cases, depending on the dimensions of e(AG). First, if e(AG) is a sentence then we know by induction that e(AG)=e(AH). Hence,
[TABLE]
Next, if e(AG) is a column vector, then we know that e(AG)=T⋅e(AH) and furthermore, since ML(L)-vectors are constant on equitable partitions, that e(AG)=∑i=1ℓai×1Vi and e(AH)=∑i=1ℓbi×1Wi for some scalars ai and bi in C, for i=1,…,ℓ. Here, 1Vi and 1Wi, for i=1,…,ℓ,
are the indicator vectors representing the equitable partitions V={V1,…,Vℓ} of G and W={W1,…,Wℓ} of H, respectively.
We first show that ai=bi, for i=1,…,ℓ. Indeed, since T⋅1=1 and T is compatible with V and W, we have that
[TABLE]
As a consequence, using that 1Vit⋅1Vja is [math] if i=j and ∣Vi∣ if i=j, we obtain
[TABLE]
for all i=1,…,ℓ. Since ∣Vi∣=∣Wi∣=0, we indeed have that ai=bi for all i=1,…,ℓ.
We may now conclude that
[TABLE]
Hence e′(AG) and e′(AH) are indeed T-conjugate.
∎
In the context of Proposition 7.3, i.e., to show that the diag(⋅) operation preserves S-conjugation (and S∗-conjugation), we need to verify that ML(⋅,∗,1,diag)-vectors are constant on equitable partitions. We verify this, in the appendix, by induction on the structure of expressions in ML(⋅,∗,1,diag).
In fact, we more generally show the following.
Proposition 7.4**.**
ML(⋅,tr,∗,1,diag,+,×,applys[f],f∈Ω)-vectors are constant on equitable partitions. ∎
All combined, we obtain the following characterisations.
Theorem 7.3**.**
Let G and H be two graphs of the same order. Then, G≡ML(⋅,∗,1,diag)H if and only if there is doubly stochastic matrix S such that AG⋅S=S⋅AH if and only if G≡C2H if and only if G and H have a common equitable partition. ∎
Proof.
This is a direct consequence of Propositions 7.1, 7.2, 7.3 and 7.4.
∎
We further complement Theorem 7.3 by observing that G≡ML(⋅,∗,1,diag)H if and only if HOMF(G)=HOMF(H) where
F consists of all trees [27].
As a consequence, following Example 7.2, sentences in ML(⋅,∗,1,diag) can distinguish G1 (
) and H1 (
), G2 (
) and H2 (
), G4 (
) and H4 (
), because all these pairs of graphs do not have a common equitable partition. By contrast, G3 (
) and H3 (
) cannot be distinguished by sentences in ML(⋅,∗,1,diag).
We remark that G≡ML(⋅,∗,1,diag)H if and only if G≡ML(⋅,∗,1,diag,+,×,applys[f],f∈Ω)H. This is again a direct consequence of the fact that G≡ML(⋅,∗,1,diag)H implies that AG⋅S=S⋅AH and AH⋅S∗=S∗⋅AG, for a doubly stochastic matrix S, and that all operations in ML(⋅,∗,1,diag,+,×,applys[f],f∈Ω) preserve S-conjugation and S∗-conjugation.
7.4 Characterisation of
ML(⋅,tr,∗,1,diag)-equivalence
We next consider ML(⋅,tr,∗,1,diag)-equivalence. We already know a couple of implications when G≡ML(⋅,tr,∗,1,diag)H holds. For example, there must exist an orthogonal matrix O such that O⋅1=1 and AG⋅O=O⋅AH (Propositions 6.4 and 6.5). Furthermore, we know that G and H must have a common equitable partition and hence, there exists a doubly stochastic matrix S such that AG⋅S=S⋅AH (Proposition 7.3). It is tempting to conjecture that G≡ML(⋅,tr,∗,1,diag)H if and only if there exists an orthogonal doubly stochastic matrix O such that AG⋅O=O⋅AH. This does not hold, however. Indeed, invertible doubly stochastic matrices are necessarily permutation matrices (see e.g., Theorem 2.1 in [29]). Then, AG⋅O=O⋅AH would imply that G and H are isomorphic, contradicting that our fragments cannot go beyond C3-equivalence [11]. Instead, we have the following characterisation.
Theorem 7.4**.**
Let G and H be two graphs of the same order. Then the following hold: G≡ML(⋅,tr,∗,1,diag)H if and only if G and H have a common equitable partition and AG⋅O=O⋅AH for some doubly quasi-stochastic orthogonal matrix O which is compatible with some equitable partitions V of G and W of H, that witness that G and H have a common equitable partition.
In the proof of Theorem 7.4 we will rely on Specht’s Theorem (see e.g., [48]), which we recall first. Let A=A1,…,Ap and B=B1,…,Bp be two sequences of complex matrices that are closed under complex conjugate transposition. That is, if Ai occurs in A then so does Ai∗; the same must hold for B.
The sequences A and B are called simultaneously unitary equivalent if there exists a unitary matrix U such that Ai⋅U=U⋅Bi, for i=1,…,p. Specht’s Theorem provides a means of checking simultaneous unitary equivalence in terms of trace identities. Indeed, Specht’s Theorem states that A and B are simultaneously unitary equivalent if and only if
[TABLE]
for all words w(x1,…,xp) over the alphabet {x1,…,xp}. In expression w(A1,…,Ap) we instantiated xi with Ai and interpret concatenation in the word w as matrix multiplication; we interpret w(B1,…,Bp) in a similar way. Specht’s Theorem also holds when A and B consist of real matrices and unitary matrices are replaced by orthogonal matrices [48]. The required condition is that A and B are closed under transposition. We next show Theorem 7.4.
Proof.
To show that the existence of a matrix O, as stated in the Theorem, implies the equivalence G≡ML(⋅,tr,∗,1,diag)H, we argue as before. More precisely, we show that O-conjugation is preserved by the operations in ML(⋅,tr,∗,1,diag). This is, however, a direct consequence of Lemmas 5.1, 5.2, 6.1 and 7.1. We remark that Proposition 7.4 guarantees that Lemma 7.1 can be applied. Indeed, Proposition 7.4 implies that ML(⋅,tr,∗,1,diag)-vectors are constant on equitable partitions. We may thus conclude that all expressions in ML(⋅,tr,∗,1,diag) preserve O-conjugation. Hence, e(AG)=e(AH) for any sentence e(X) in ML(⋅,tr,∗,1,diag).
For the converse direction, we need to show that G≡ML(⋅,tr,∗,1,diag)H implies that there exists an orthogonal matrix O such that AG⋅O=O⋅AH, and where O satisfies the conditions mentioned in the statement of the Theorem.
The existence of the orthogonal matrix O is shown using Specht’s Theorem, which we just recalled. This is done as follows: We first rephrase the conditions required for O, i.e., that it is a doubly quasi-stochastic matrix which is compatible with some equitable partitions V and W of G and H, respectively, in terms of such trace identities. Then we show that these trace identities can be expressed by sentences in ML(⋅,tr,∗,1,diag).
We note that our approach is inspired by Thüne [68]. In that work, simultaneous unitary equivalence of graphs is studied with respect to their so-called [math], 1 and 2-dimensional Weisfeiler-Lehman closures. Here, we consider simultaneous orthogonal equivalence with respect to all possible matrices that can be obtained using ML(⋅,tr,∗,1,diag)-expressions.
We start by defining the sequences A and B on which we will apply Specht’s Theorem. Consider the sequences of real symmetric matrices: A:=AG,J,diag(1V1),…,diag(1Vℓ) and B:=AH,J,diag(1W1),…,diag(1Wℓ), where 1Vi and 1Wi, for i=1,…,ℓ, denote the indicator vectors corresponding to the coarsest equitable partitions V={V1,…,Vℓ} and W={W1,…,Wℓ} of G and H, respectively. We observe that A and B are closed under transposition. By the real counterpart of Specht’s Theorem we can check whether there exists an orthogonal matrix O such that
[TABLE]
hold, for i=1,…,ℓ, in terms of trace identities. It is clear that conditions (2) and (4) express that AG and AH must be O-conjugate and that O must be compatible with V and W. The orthogonality of O is implied by Specht’s Theorem. Condition (3) ensures that we can choose O such that O⋅1=1 holds. To see this, we next modify the proof of Lemma 4 in Thüne [68], stated for unitary matrices, so that it holds for orthogonal matrices.
We first observe that 1 is an eigenvector of O. Indeed, J⋅O⋅1=1⋅(1t⋅O⋅1)=α×1 with α=1t⋅O⋅1 and J⋅O⋅1=O⋅J⋅1=(1t⋅1)×O⋅1. In other words, O⋅1=nα×1 since 1t⋅1=n. Furthermore, because 1t⋅Ot⋅1 is a scalar, 1t⋅Ot⋅1=(1t⋅Ot⋅1)t=1t⋅O⋅1=α. We next show that α=±n. Indeed, since O is an orthogonal matrix
[TABLE]
and thus α2=n2 or α=±n. Hence, O⋅1=±1. When O⋅1=1, O is already doubly quasi-stochastic. In case when O⋅1=−1, we simply replace O by (−1)×O to obtain that O⋅1=1. This rescaling does not impact the validity of conditions (2) and (4). Hence, O can indeed be assumed to be doubly quasi-stochastic.
It remains to show that the trace identities implying the existence of an orthogonal matrix O satisfying conditions (2), (3) and (4) can be expressed in ML(⋅,tr,∗,1,diag). For every word w(x,j,b1,…,bℓ) we consider the sentence
[TABLE]
in which variables x,j,b1,…,bℓ are assigned to matrix variable X, expression 1(X)⋅(1(X))∗ (which evaluates to J), and expressions diag(eqparti(X)), for i=1,…,ℓ, respectively. Here, the expressions eqparti(X) correspond to the expressions extracting the indicator vectors of the (coarsest) equitable partition of a graph, as defined in the proof of Proposition 7.2. We recall from that proof that eqparti(X) are expressible in ML(⋅,tr,∗,1,diag,+,×).
As a consequence, the sentences ew(X) belong to ML(⋅,tr,∗,1,diag,+,×). We have seen, however, in the proof of Proposition 7.2, that
G≡ML(⋅,tr,∗,1,diag)H implies
G≡ML(⋅,tr,∗,1,diag,+,×)H.
Hence, G≡ML(⋅,tr,∗,1,diag)H implies that ew(AG)=ew(AH) for every word w.
∎
We note that G≡ML(⋅,tr,∗,1,diag)H implies G≡ML(⋅,∗,1,diag)H. The converse does not hold, as is illustrated next.
Example 7.5**.**
Consider G3 (
) and H3 (
). These graphs are fractional isomorphic (and thus ML(⋅,∗,1,diag)-equivalent) but are not co-spectral. Hence, G3≡ML(⋅,tr,∗,1,diag)H3 since ML(⋅,tr,∗,1,diag)-equivalence implies co-spectrality. On the other hand, G5 (
) and H5 (
) are co-spectral regular graphs (Figure 2 in van Dam et al. [71]), with co-spectral complements. The equitable partitions V of G5 and W of H5, consisting of a single part containing all vertices, witness that G5 and H5 have a common equitable partition. We thus know from before that there exists an orthogonal matrix O such that AG5⋅O=O⋅AH5 and O⋅1=1 (this follows from G5 and H5 being co-spectral and co-main). Moreover, the compatibility requirement with V and W is vacuously satisfied. Indeed, these partitions are represented by the indicator vector 1 and we note that diag(1)⋅O=O⋅diag(1) always holds. Hence, G5 and H5 cannot be distinguished by ML(⋅,tr,∗,1,diag) by Theorem 7.4. ∎
It would be tempting to conjecture that G≡ML(⋅,tr,∗,1,diag)H if and only if G and H are co-spectral and have a common equitable partition. It is clearly a necessary condition. We see in the next Section, however, that there exists graphs that are co-spectral and have a common equitable partition, yet are not ML(⋅,tr,∗,1,diag)-equivalent.
We remark that G≡ML(⋅,tr,∗,1,diag)H if and only if G≡ML(⋅.tr,∗,1,diag,+,×,applys[f],f∈Ω)H. This is again a direct consequence of the fact that G≡ML(⋅,tr,∗,1,diag)H implies that AG⋅O=O⋅AH, AH⋅O∗=O∗⋅AG, for an orthogonal doubly quasi-stochastic matrix O which is compatible with equitable partitions of G and H, that witness that G and H have a common equitable partition. Furthermore, for such matrices O, we observe that all operations in ML(⋅,tr,∗,1,diag,+,×,applys[f],f∈Ω) preserve O-conjugation and O∗-conjugation.
7.5 Pointwise function applications on vectors
A crucial ingredient for obtaining characterisations of equivalence in the presence of the diag(⋅) operation is that vectors are constant on equitable partitions (Proposition 7.4 and Lemma 7.1). In this way, vectors obtained by evaluating expressions on equivalent AG and AH are “almost” the same, up to the use of indicator vectors. More precisely,
when e(AG)=∑i=1ℓai×1Vi then e(AH)=∑i=1ℓai×1Wi, and vice versa.
We next show that this tight relationship between vectors computed from AG and AH allows us to extend the matrix query languages considered in this section with pointwise function applications on vectors. More precisely, we denote by applyv[f], for f∈Ω, that we only allow function applications of the form e(X):=applyv[f](e1(X),…,ep(X)) where each ei(X) returns a vector when evaluated on a matrix.
Proposition 7.5**.**
Let G and H be two graphs of the same order.
(1)
G≡ML(⋅,∗,1,diag)H* if and only if G≡ML(⋅,∗,1,diag,+,×,applys[f],applyv[f],f∈Ω)H.*
(2)
G≡ML(⋅,tr,∗,1,diag)H* if and only if G≡ML(⋅,tr,∗,1,diag,+,×,applys[f],applyv[f],f∈Ω)H.*
Proof.
In view of the previous results, it suffices to show that (1) ML(⋅,∗,1,diag,+,×,applys[f],f∈Ω)-equivalence implies ML(⋅,∗,1,diag,+,×,applys[f],applyv[f],f∈Ω)-equivalence; and that (2) ML(⋅,tr,∗,1,diag,+,×,applys[f],f∈Ω)-equivalence implies ML(⋅,tr,∗,1,diag,+,×,applys[f],applyv[f],f∈Ω)-equivalence. Both implication follow if we can show that ML(⋅,tr,∗,1,diag,+,×,applys[f],applyv[f],f∈Ω)-vectors are constant on equitable partitions and that applyv[f], for f∈Ω, preserves conjugation by quasi doubly-stochastic matrices that are compatible with equitable partitions of G and H that witness that G and H have a common equitable partition.
For conciseness, let L† denote {⋅,tr,∗,1,diag,+,×,applys[f]applyv[f],f∈Ω}, i.e., L† consists of all operations considered so far. Proposition 7.4 (being constant on partitions) trivially generalizes to ML(L†)-vectors.
Indeed, it suffices to consider the case
[TABLE]
where e1(X),…,ep(X) are expressions in ML(L†) such that each ei(AG) returns a vector. We may assume by induction that for i=1,…,p, ei(AG)=∑j=1ℓaj(i)×1Vi
for scalars aj(i)∈C, for j=1,…,ℓ, and where 1Vi, for i=1,…,ℓ, are indicator vectors representing an equitable partition of G.
Since the sets of entries in the indicator vectors holding value 1 are disjoint for any two different indicator vectors, we have that
[TABLE]
So, indeed, ML(L†)-vectors are constant on equitable partitions.
Let V={V1,…,Vℓ} and W={W1,…,Wℓ} be equitable partitions of G and H, respectively. Suppose that these partitions witness that G and H have a common equitable partition. That T-conjugation, for a quasi doubly-stochastic matrices T that is compatible with V and W, is also preserved by pointwise function applications on vectors now easily follows. Indeed, consider e(X):=applyv[f](e1(X),…,ep(X)). By assumption, ei(AG)=T⋅ei(AH) for all i=1,…,p. Furthermore,
ei(AG)=∑j=1ℓaj(i)×1Vi and ei(AH)=∑j=1ℓbj(i)×1Wi. The indicator vectors 1Vi and 1Wi, for i=1,…,ℓ, represent the partitions V and W, as before.
We have seen in the proof of Lemma 7.1 that T-conjugation of these vectors implies aj(i)=bj(i) for j=1,…,ℓ and i=1,…,p.
As a consequence, e(AG) is equal to
[TABLE]
which is equal to T⋅e(AH), as desired.
∎
Going back to the graphs G5 (
) and H5 (
) in Example 7.5, these cannot even be distinguished by sentences in the large fragments in Proposition 7.5. In Section 9, we show that by allowing pointwise function applications on matrices, and in particular the Schur-Hadamard product, we can distinguish these two graphs.
8 The impact of pointwise multiplication on vectors
In the preceding section the main use of the diag(⋅) operation related to the construction of the coarsest equitable partition (see e.g., the proof of Proposition 7.2) and more specifically, to the ability to pointwise multiply two vectors (see e.g., Example 7.1). In this section we investigate how ML(⋅,∗,1,diag)-equivalence and ML(⋅,tr,∗,1,diag)-equivalence change if we replace the diag(⋅) operation with the operation, denoted by ⊙v, which pointwise multiplies vectors.
We first remark that e1(X)⊙ve2(X) can be expressed as diag(e1(X))⋅diag(e2(X))⋅1(X). So surely,
G≡ML(⋅,∗,1,diag)H implies G≡ML(⋅,∗,1,⊙v)H. We show below that the converse also holds.
For this fragment, it thus does not matter whether we include diag(⋅) or ⊙v.
Similarly, G≡ML(⋅,tr,∗,1,diag)H implies G≡ML(⋅,tr,∗,1,⊙v)H.
The converse, however, does not hold as we will show below555It was incorrectly stated in the conference version [33] that diag(⋅) and ⊙v are interchangeable.. Finally, G≡ML(⋅,tr,∗,1,⊙v)H trivially implies G≡ML(⋅,∗,1,⊙v)H. The results in this section show that the converse does not hold.
Example 8.1**.**
Consider the graphs
G6 (
) and H6 (
)666I am indebted to David E. Roberson for providing these two graphs [64].. On can verify that these graphs are co-spectral and have a common equitable partition (and thus also have co-spectral complements).
Using the diagonal operation we can construct the Laplacian of a graph by simply considering expression L(X):=(diag(X⋅1(X))−X. It is now easy to detect that G6
and H6 have Laplacians that are not co-spectral. Indeed, consider the ML(⋅,tr,∗,1,diag,+,×) expression eL,k(X):=tr(L(X)k). Then, we can check that eL,3(AG6)=1602=1618=eL,3(AH6). The relation between co-spectrality and traces of powers of matrices (cfr. Proposition 5.1) holds more generally for symmetric matrices (this follows easily from the real version of Specht’s Theorem used in the proof of Theorem 7.4).
Hence, we can infer that the Laplacians of G6 and H6 are not co-spectral.
Another way of verifying this is that G6 and H6 have a different number of spanning trees (192 versus 160) and Kirchhoff’s matrix tree theorem (see e.g., Proposition 1.3.4 in [14]) implies that graphs with co-spectral Laplacians must have the same number of spanning trees. Hence, G6 and H6 can be distinguished by ML(⋅,tr,∗,1,diag,+,×) (and hence also by sentences in ML(⋅,tr,∗,1,diag) as we have seen before). Nevertheless, we will see that G6 and H6 cannot be distinguished by sentences in ML(⋅,tr,∗,1,⊙v). More generally, we show that two graphs are ML(⋅,tr,∗,1,⊙v)-equivalent if and only if they are co-spectral and have a common equitable partition (see Proposition 8.3 below). ∎
As mentioned earlier, when considering ML(⋅,∗,1,diag) one can equivalently use ⊙v instead of diag(⋅).
Proposition 8.1**.**
Let G and H be two graphs of the same order. Then, G≡ML(⋅,∗,1,⊙v)H if and only if
G≡ML(⋅,∗,1,diag)H.
Proof.
We already observed at the beginning of this section that G≡ML(⋅,∗,1,diag)H implies G≡ML(⋅,∗,1,⊙v)H.
It remains to show the reverse implication. This can be proved by
a simple inductive argument, transforming sentences in ML(⋅,∗,1,diag,⊙v) into sentences without diag(⋅).
With each sentence e(X) in ML(⋅,∗,1,diag,⊙v)
we associate, in a natural way, the number of occurrences, denoted by k, of the diag(⋅) operation in this sentence.
We will show, by induction on k,
that any sentence e(X) in ML(⋅,∗,1,diag,⊙v) is equivalent to a sentence e~(X) in ML(⋅,∗,1,⊙v). Here, equivalence of sentences means that e(A)=e~(A) for any input matrix A. Consider a sentence e(X) in ML(⋅,∗,1,diag,⊙v).
Clearly, if k=0, then e(X)
is already a sentence in ML(⋅,∗,1,⊙v). Assume now that any sentence
e(X) in ML(⋅,∗,1,diag,⊙v) with k occurrences is equivalent to a sentence e~(X) in ML(⋅,∗,1,⊙v).
Consider a sentence e(X) in ML(⋅,∗,1,diag,⊙v) having k+1 occurrences of diag(⋅).
Since e(X) is a sentence, we can write
e(X) as e1(X)⋅diag(e2(X))⋅e3(X), where e1(X), e2(X) and e3(X) are expressions in ML(⋅,∗,1,diag,⊙v). We will next eliminate the occurrence of diag(⋅) in diag(e2(X)). We distinguish between the following two cases, depending on the dimension of e2(A), were A is an n×n-matrix. Suppose first that e2(A) is a scalar. Clearly, in this case diag(e2(X)) is equivalent to e2(X) and hence e(X) is equivalent to the expression e′(X):=e1(X)⋅e2(X)⋅e3(X). Suppose next that e2(A) evaluates to an n×1 column vector, with n>1. Then, necessarily, e1(A) evaluates to a 1×n row vector and
e3(A) evaluates to an n×1 column vector. This implies that e(X) is equivalent to e′(X):=e1(X)⋅(e2(X)⊙ve3(X)). We remark that in both cases, e′(X) is an expression in ML(⋅,∗,1,diag,⊙v)
consisting of k occurrences of diag(⋅). By the induction hypothesis, e′(X) (and hence also e(X)) is indeed equivalent to a sentence e~(X) in
ML(⋅,∗,1,⊙v), as desired. Hence, G≡ML(⋅,∗,1,⊙v)H implies G≡ML(⋅,∗,1,diag)H.
∎
The above proof fails when the trace operation is present. The reason is that we can have sentences like eL,k(X) in Example 8.1, which cannot be decomposed as e1(X)⋅diag(e2(X))⋅e3(X). The previous proof crucially relies on the fact that all sentences can be written in that form.
We next consider ML(⋅,tr,∗,1,⊙v). To analyse the distinguishability of graphs by sentences in this fragment, we follow the same approach as for ML(⋅,tr,∗,1,diag).
Corollary 8.2**.**
Let G and H be two graphs of the same order. Then, G≡ML(⋅,tr,∗,1,⊙v)H implies that G and H have a common equitable partition.
Proof.
This is a direct consequence of Propositions 7.2 and 8.1. Indeed, we know already that
G≡ML(⋅,∗,1,diag)H implies that
G and H have a common equitable partition and we have just shown that G≡ML(⋅,∗,1,diag)H if and only if
G≡ML(⋅,∗,1,⊙v)H. It now suffices to observe that ML(⋅,∗,1,⊙v) is a smaller fragment than ML(⋅,tr,∗,1,⊙v).∎
Furthermore, we can add pointwise vector multiplication to the list of operations in Proposition 7.4. We defer the proof to the appendix.
Proposition 8.2**.**
ML(⋅,tr,∗,1,diag,⊙v,diag,+,×,applys[f],f∈Ω)-vectors are constant on equitable partitions. ∎
It remains to identify an appropriate class of matrices for which conjugation is preserved by pointwise vector multiplication. Let G and H be two graphs that have a common equitable partition.
As before, let V={V1,…,Vℓ} and W={W1,…,Wℓ} be equitable partitions of G and H, respectively. The corresponding
indicator vectors are denoted by 1Vi and 1Wi, for i=1,…,ℓ, respectively. We say that a matrix Tpreserves the partitions V and W
if 1Vi=T⋅1Wi
for all i=1,…,ℓ.
We note that this condition is weaker than the compatibility notion used before (see the proof of Lemma 7.1 where we verified the preservation of partitions for matrices that are compatible with these partitions).
Lemma 8.1**.**
Let ML(L) be a matrix query language such that ML(L)-vectors are constant on equitable partitions. Let G and H be two graphs of the same order and let V and W be equitable partitions of G and H, respectively. Assume that V and W witness that G and H have a common equitable partition. Furthermore,
let T be a matrix which preserves V and W. Finally, Let e1(X) and e2(X) be expressions in ML(L) which evaluate to vectors. Then, if e1(AG) and e1(AH) are T-conjugate, and e2(AG) and e2(AH) are T-conjugate,
then also e1(AG)⊙ve2(AG) and e1(AH)⊙ve2(AH) are T-conjugate.
Proof.
The proof is similar to the proof of Lemma 7.1. Consider e(X):=e1(X)⊙ve2(X). We distinguish between two cases, depending on the dimensions of e(AG). First, if e(AG) is a sentence then we know by induction that e1(AG)=e1(AH) and e2(AG)=e2(AH). Hence,
[TABLE]
Next, if e1(AG) and e2(AG) are (column) vectors, then we know that e1(AG)=T⋅e1(AH) and e2(AG)=T⋅e2(AH).
We argued in the proof of Lemma 7.1 that when 1Vi=T⋅1Wi holds for i=1,…,ℓ, then since vectors are constant on equitable partitions,
e1(AG)=∑i=1ℓai×1Vi=∑i=1ℓai×(T⋅1Wi)=T⋅e1(AH) and
e2(AG)=∑i=1ℓbi×1Vi=∑i=1ℓbi×(T⋅1Wi)=T⋅e2(AH). We may now conclude that
[TABLE]
Hence, e(AG) and e(AH) are indeed T-conjugate.
∎
We can now state a characterisation of ML(⋅,tr,∗,1,⊙v)-equivalence.
Theorem 8.3**.**
Let G and H be two graphs of the same order. Let V and W be equitable partitions of G and H, respectively, that witness that G and H have a common equitable partition.
Then,
G≡ML(⋅,tr,∗,1,⊙v)H if and only if there exists an orthogonal matrix O which preserves V and W and such that AG⋅O=O⋅AH.
Proof.
To show that the existence of a matrix O, as stated in the Theorem, implies G≡ML(⋅,tr,∗,1,⊙v)H, we argue as before. More precisely, we show that O-conjugation and O∗-conjugation is preserved by the operations in ML(⋅,tr,∗,1,⊙v). This is, however, a direct consequence of Lemmas 5.1, 5.2, 5.4, 6.1 and 8.1. We remark that Proposition 8.2 guarantees that Lemma 8.1 can be applied. Indeed, Proposition 8.2 implies that ML(⋅,tr,∗,1,⊙v)-vectors are constant on equitable partitions. Furthermore, since 1Vi=O⋅1Wi, for all i=1,…,ℓ, and 1=∑i=1ℓ1Vi=∑i=1ℓ1Wi, we have that 1=O⋅1. Hence, O is doubly quasi-stochastic and Lemma 6.1 applies. Moreover, if AG⋅O=O⋅AH then AH⋅O∗=O∗⋅AG due to the orthogonality of O, and O∗ preserves W and V. Hence, Lemma 5.4 applies.
We may thus conclude that all expressions in ML(⋅,tr,∗,1,⊙v) preserve O- and O∗-conjugation. Hence, e(AG)=e(AH) for any sentence e(X) in ML(⋅,tr,∗,1,⊙v).
For the converse direction, we need to show that G≡ML(⋅,∗,tr,1,⊙v)H implies that there exists an orthogonal matrix O such that AG⋅O=O⋅AH, and where O preserves the partitions V and W.
This can be shown, just like in the proof of Theorem 7.4, by means of trace conditions. In particular, we impose trace conditions such that O satisfies AG⋅O=O⋅AH and (1Vi⋅(1Vi)∗)⋅O=O⋅(1Wi⋅(1Wi)∗),
for i=1,…,ℓ. These conditions replace conditions (3) and (4) in the proof of Theorem 7.4. We show in the appendix that this indeed implies that O can be chosen such that it preserves V and W. The argument is based on a generalisation of Lemma 4 in Thüne [68]. As in the proof of Theorem 7.4, the trace conditions ew(X) which ensure the existence of an orthogonal matrix O such that (1Vi⋅(1Vi)∗)⋅O=O⋅(1Wi⋅(1Wi)∗) holds for i=1,…,ℓ, rely on the expressions eqparti(X) (from the proof of Proposition 7.2). These expressions use addition and scalar multiplication. It is now easily verified (see appendix) that G≡ML(⋅,tr,∗,1,⊙v)H
implies G≡ML(⋅,tr,∗,1,⊙v,+,×)H and hence, G≡ML(⋅,tr,∗,1,⊙v)H
implies that
ew(AG)=ew(AH). ∎
As it turns out, ML(⋅,tr,∗,1,⊙v)-equivalence precisely captures co-spectral and fractional isomorphic graphs.
Proposition 8.3**.**
Let G and H be graphs of the same order. Then, G≡ML(⋅,tr,∗,1,⊙v)H if and only if G and H are co-spectral and have a common equitable partition.
We also observe that G≡ML(⋅,tr,∗,1,⊙v)H if and only if HOMF(G)=HOMF(H) where
F consists of all trees and cycles. This follows from the results in Dell et al. [27].
Proof.
If G≡ML(⋅,tr,∗,1,⊙v)H, then G and H must have a common equitable partition by Corollary 8.2.
Furthermore, we know from Propositions 5.1 and 5.2, that G and H must also be co-spectral.
For the converse, we explicitly construct an orthogonal matrix O such that AG⋅O=O⋅AH and O preserves equitable partitions of G and H that witness that G and H have a common equitable partition.
Then, Theorem 8.3 implies that G≡ML(⋅,tr,∗,1,⊙v)H holds.
We next construct the matrix O.
Let G and H be two graphs of order n and assume that V={V1,…,Vℓ} and W={W1,…,Wℓ} are equitable partitions of G and H, respectively, that witness that G and H have a common equitable partition. As before, we denote by 1V1,…,1Vℓ the indicator vectors corresponding to V and by
1W1,…,1Wℓ the indicator vectors corresponding to W.
We first observe the following. It is known that, for indicator vectors representing an equitable partition, the subspace UG=span(1V1,…,1Vℓ) of Cn is an AG-invariant subspace (see e.g., Lemma 5.2 in [16]).
In other words, for any v∈UG, AG⋅v∈UG. Furthermore, since AG is a symmetric matrix, also the orthogonal complement subspace UG⊥ is AG-invariant
(see e.g., Theorem 36 in [50]). Here, UG⊥ consists of all vectors v′ in Cn that are orthogonal to any vector v∈UG, i.e., such vt⋅v′=0 holds.
Let us interpret AG as the linear operator TG:Cn→Cn:v↦AG⋅v. This is a diagonalisable operator (because AG is symmetric) and it is known that
the restrictions TG∣UG and TG∣UG⊥ are also diagonalisable operators (because of the invariance of these two subspaces (see e.g., Corollary 15.9 in [36])). This implies, as this is merely a restatement of a linear operator to be diagonalisable, that
there exists eigenvectors v1,…,vℓ,v1′,…,vn−ℓ′ of AG such that UG=span(v1,…,vℓ) and UG⊥=span(v1′,…,vn−ℓ′).
Furthermore, if we denote by PG the matrix with columns 1V1,…,1Vℓ, then AG⋅PG=PG⋅C with C the ℓ×ℓ-matrix
such that Cij=deg(v,Vj) for some (arbitrary) vertex v∈Vi (see e.g., Lemma 6.1 in [16]). Also Cij is diagonalisable (this follows from the fact that the characteristic polynomial of C divides that of AG (see e.g., Theorem 6.2 in [16])
and hence there exists ℓ linearly independent eigenvectors c1,…,cℓ of C777We here use that we work in the algebraically closed field C for which being diagonalisable coincides with the minimal polynomial being a product of monic linear factors of the form (x−λ). So, since
the characteristic polynomial of C divides that of AG, also the minimal polynomial of C divides that of AG. Since AG is diagonalisable, its minimal polynomial is a product of monic linear factors. Hence, also the minimal polynomial of C has this form and C is diagonalisable as well.. It is known that vi=PG⋅ci, for i=1,…,ℓ, are independent
eigenvectors of AG. More precisely, if C⋅ci=λi×ci then AG⋅(PG⋅ci)=λi×(PG⋅ci).
Moreover, PG⋅ci∈UG, for i=1,…,ℓ. We may thus assume
that UG is spanned by PG⋅c1,…,PG⋅cℓ.
The reasoning above also holds for AH, i.e., there are eigenvectors w1,…,wℓ,w1′,…,wn−ℓ′ of AH such that UH=span(w1,…,wℓ) and UH⊥=span(w1′,…,wn−ℓ′).
Important to observe here is that V and W witness that G and H have a common equitable partition. As a consequence, AH⋅PH=PH⋅C, where PH is now the matrix with columns 1W1,…,1Wℓ and C is the same ℓ×ℓ-matrix as used above.
We may thus assume
that UH is spanned by PH⋅c1,…,PH⋅cℓ and furthermore, PG⋅ci and PH⋅ci are eigenvectors of AG and AH, respectively, both belonging to
the same eigenvalue λi of C.
We next use that G and H are co-spectral. The argument above, combined with co-spectrality, implies that the (multi-set) of eigenvalues corresponding to the eigenvectors spanning UG and UH are
the same. This implies in turn, by co-spectrality, that we may also assume that AG⋅vi′=λi×vi′ and AH⋅wi′=λi×wi′, for i=1,…,n−ℓ, for some eigenvalues λi
of AG (and AH). We recall that UG and UH are also spanned by
1Vi,…,1Vℓ and 1W1,…,1Wℓ, respectively. This implies, that the eigenvectors spanning UG⊥ and UH⊥ are necessarily orthogonal
to these indicator vectors.
We define O as the matrix OG⋅OHt, where OG is the orthogonal matrix whose columns consist of the vectors n111V1,…,nℓ11Vℓ,v1′,…,vn−ℓ′
and OH is the orthogonal matrix whose columns consist of the vectors n111W1,…,nℓ11Wℓ,w1′,…,wn−ℓ′, where ni=∣Vi∣=∣Wi∣ and where we assume the
eigenvectors vi′ and wi′ to be normalised. As a consequence, O is clearly an orthogonal matrix and thus O⋅Ot=I=Ot⋅O holds. In view of the construction of the eigenvectors,
we have the following more explicit expression for O:
[TABLE]
We verify the required conditions.
To begin with, we note that O⋅1Wi=1Vi, for i=1,…,ℓ. Indeed, this follows from the fact that
1Wjt⋅1Wi is zero when i=j and is ∣Wi∣=ni when i=j. Moreover, (wj′)t⋅1Wi=0 because of wj′∈UH⊥, for all j=1,…,n−ℓ.
Hence, O indeed preserves V and W.
It remains to verify that
AG⋅O=O⋅AH. We verify this for both terms in the above expression for O. Since vi′ and wi′ are eigenvectors of AG and AH, respectively, belonging to the
same eigenvalue λi, we have for the second term:
[TABLE]
For the first term in the expression for O, we consider the matrices
[TABLE]
for some (arbitrary) vertices vi∈Vi and wi∈Wi. We here used that the indicator vectors represent equitable partitions.
We now look at the entries in the matrices BG and BH and observe that J=∑i,j=1ℓ1Vj⋅1Wit. Hence, for each p,q∈{1,…,n} we can define
f(p) and g(q) as the unique indexes of indicator vectors 1Vf(p) and 1Wg(q) such that they hold value 1 at position p and q, respectively.
Then,
[TABLE]
because the indicator vectors correspond to equitable partitions that witness that G and H have a common equitable partition. Hence, we may indeed conclude that AG⋅O=O⋅AH.
∎
Example 8.4**.**
We already mentioned that the graphs
G6 (
) and H6 (
) are co-spectral and have a common equitable partition. Proposition 8.3 implies that
G6≡ML(⋅,tr,∗,1,⊙v)H6, as anticipated. ∎
We mention that we can extend ML(⋅,tr,∗,1,⊙v) with +, ×, and pointwise function applications
on scalars and vectors, without increasing the distinguishing power of the fragments. This can be shown in precisely the same way as before
by showing that O- and O∗-conjugation is preserved by these operations when O is an orthogonal matrix which preserves
equitable partitions (that witness that the graphs have a common equitable partition).
Finally, we separate distinguishability by ML(⋅,tr,∗,1,⊙v) and ML(⋅,∗,1,⊙v).
It suffices to consider the graphs
G3 (
) and H3 (
) which are fractionally isomorphic but not co-spectral.
Proposition 8.1 implies that these are indistinguishable by ML(⋅,∗,1,⊙v).
Proposition 8.3 implies that they can be distinguished by ML(⋅,tr,∗,1,⊙v).
9 The impact of pointwise functions on matrices
The final operation that we consider is pointwise function applications on matrices. In particular, we start by considering the Schur-Hadamard product, which we denote by the binary operation ⊙, i.e., (A⊙B)ij=AijBij for matrices A and B. Our results will imply that once two
graphs are equivalent with regards to sentences in ML(⋅,tr,∗,1,diag,⊙), then they will be equivalent with regards to sentences in ML(⋅,tr,∗,1,diag,⊙,apply[f],f∈Ω)
for any pointwise function application apply[f], be it on scalars, vectors or matrices. That is, the graphs will be MATLANG-equivalent.
This section is structured in a similar way as Section 7. More precisely, we first illustrate the additional power that the Schur-Hadamard product provides by means of an example in
Section 9.1. Then, in Section 9.2 we show that we can compute a so-called
stable edge partition of a graph by means of expressions in ML(⋅,tr,∗,1,diag,⊙,+,×). Such an edge partition can be regarded as a generalisation of the notion of equitable partition. Stable edge partitions can be obtained as the result of the edge colouring or 2-dimensional Weisfeiler-Lehman (2WL) algorithm.
In Section 9.2, we also show that G≡ML(⋅,tr,∗,1,diag,⊙)H implies that G and H are indistinguishable by the 2WL-algorithm. It is known from the seminal paper by Cai, Fürer and Immerman [15], that this is equivalent to C3-equivalence.
Based on this, in Section 9.3 we prove the main result of this section, i.e., that G≡ML(⋅,tr,∗,1,diag,⊙)H if and only if
G≡MATLANGH if and only if G≡C3H.
We remark that from the work by Brijder et al. [11] it implicitly follows that C3-equivalence implies MATLANG-equivalence. Our results thus show that converse implication also holds. That is, MATLANG-equivalence coincides with
C3-equivalence.
9.1 Example of the impact of the presence of Schur-Hadamard product
We start with an example showing what extra information can be computed from graphs when the Schur-Hadamard product is present.
Example 9.1**.**
We recall that in expression #3degr(X) in Example 7.1, products of diagonal matrices resulted in the ability to zoom in on vertices that carry specific degree information. When diagonal matrices are concerned, the product of matrices coincides with pointwise multiplication of the vectors on the diagonals. Allowing pointwise multiplication on matrices has the same effect, but now on edges in graphs. As an example, suppose that we want to count the number of “triangle walks” in G, i.e., walks (v0,…,vk) of length k in G such that each edge {vi−1,vi} in the walk is part of a triangle. This can be done by expression
[TABLE]
where f>0(x)=1 if x=0 and f>0(x)=0 otherwise888The use of apply[f>0](⋅) is just for convenience. Its application inside sentences can be simulated with operations in ML(⋅,∗,tr,1,diag,⊙) when evaluated on given adjacency matrices.. Indeed, when evaluated on adjacency matrix AG, AG2⊙AG extracts from AG2 only those entries corresponding to paths (u,v,w) of length 2 such that (u,w) is an edge as well, i.e., it identifies edges involved in triangles in G. Then, apply[f>0](AG2⊙AG) sets all non-zero entries to 1. By considering the kth power of this matrix and summing up all its entries, the number of triangle paths of length k is obtained. It can be verified that for graphs G5 (
) and H5 (
), #Δpaths2(AG5)=[160]=[132]=#Δpaths2(AH5) and hence, they can be distinguished when the Schur-Hadamard product is available. Recall that all previous fragments could not distinguish between these two graphs. ∎
As mentioned earlier, we will use the Schur-Hadamard product to compute stable edge partitions of graphs, obtained as the result of the edge colouring or 2-dimensional Weisfeiler-Lehman (2WL) algorithm [8, 15, 60, 73]. Such partitions can be seen as a generalization of equitable partitions, but now partitioning all pairs of vertices, rather than single vertices. We detail these notions next.
9.2 Stable edge partitions
We first recall the notion of stable edge partition and define when two graphs are
indistinguishable by the 2WL algorithm. Then,
similarly to the proof of Proposition 7.2, we show that when two
graphs are indistinguishable by sentences in ML(⋅,tr,∗,1,diag,⊙), then they are indistinguishable by the 2WL algorithm (Proposition 9.1 below).
As already mentioned, the stable edge partition of a graph G=(V,E) arises as the result of applying the 2WL-algorithm [8, 15, 60, 73] on G. In Algorithm 2 we provide the pseudo-code of the algorithm 2-Stab, taken from Bastert [8], which implements the 2WL-algorithm. In a nutshell, the algorithm starts by assigning every vertex pair a colour, and then revises colourings iteratively based on some structural information. When no revision of the colouring occurs, the colouring has stabilized, the algorithm stops and returns the stable colouring. Colourings naturally induce partitions of V×V, by simply grouping together vertex pairs with the same colour. The stable edge partition of G is the partition induced by the stable colouring returned by 2-Stab. The algorithm 2-Stab needs at most n2 iterations when evaluated on a graph of order n.
More precisely, in this context, a colouringχ assigns a colour to each vertex pair in V×V, i.e., if we denote by C a set of colours, it is a function χ:V×V→C. The partition of V×V induced by χ is denoted by Πχ(G) and will be represented by indicator matrices, one for each colour c∈C. Assume that V={1,…,n}. An indicator matrix for a subset Y⊆V×V
is a matrix EY in Rn×n such that (EY)v1v2=1 if (v1,v2)∈Y
and (EY)v1v2=0 otherwise. For a colour c∈C, we denote by Ec the indicator matrix for {(v1,v2)∈V×V∣χ(v1,v2)=c}.
Hence, Πχ(G) is represented by the indicator matrices Ec, for c∈C.
Algorithm 2-Stab starts (on lines 1 and 2) with an initial colouring χ0:V×V→{0,1,2} encoding adjacency, non-adjacency and loop information. More precisely, for vertices v,w∈V, χ0(v,v)=2, χ0(v,w)=1 if (v,w)∈E, and χ0(v,w)=0 for v=w and (v,w)∈E. Then, 2-Stab adjusts the current colouring in each iteration, as follows.
Suppose that the current colouring is χ:V×V→C. Given this colouring, for each pair of vertices v1,v2∈V, the so-called structure listL2(v1,v2) is computed (lines 4 and 5). To define these lists, the structure constants are needed, which are defined as
[TABLE]
for colours c and d in C and vertices v1 and v2 in V. These numbers count the number of triangles999With a triangle one simply means a triple (v1,v2), (v1,v3) and (v2,v3) of vertex pairs, none of which has to be an edge in G., based on (v1,v2) whose other two pairs of vertices (v1,v3) and (v3,v2) have prescribed colours c and d, respectively. Then, in a structure list we simply gather all these numbers for a specific vertex pair. That is,
[TABLE]
Based on this information, 2-Stab will assign new colours to pairs of vertices (lines 6–8). More precisely, C is replaced by a minimal set of colours C′ such that each unique L2(v1,v2) corresponds precisely to a single colour c′ in C′. Hence, the new colouring χ′:V×V→C′ will assign (v1′,v2′) the colour c′, corresponding to L2(v1,v2), when L2(v1,v2)=L2(v1′,v2′). It is easily verified that the partition Πχ′(G) is a refinement of Πχ(G), which in turn is a refinement of Πχ0(G).
Algorithm
2-Stab now replaces χ by χ′ and C by C′ (lines 9 and 10), and repeats this process until the number of colours remains fixed (line 11). In other words, the corresponding partition is not further refined. The algorithm then returns this final (stable) colouring.
The stable edge partition of G, denoted by Π(G), is now the partition induced by the stable colouring. It is known that Π(G) is the unique coarsest partition of V×V which refines Πχ0(G) and corresponding to a colouring satisfying the stability condition stated on lines 7 and 8 in Algorithm 2.
Two graphs G=(V,E) and H=(W,F) of the same order are now said to be indistinguishable by the 2WL algorithm, denoted by G≡2WLH, if the stable
edge partitions Π(G) and Π(H) of G and H, respectively, are (i) of the form Π(G)={Ec1,…,Ecℓ} and Π(H)={Fc1,…,Fcℓ}, that is, the parts in the partitions correspond to the same colours; and (ii) the corresponding parts in these partitions have the same size, that is, Eci and Fci have the same number of entries carrying the value 1, for i=1,…,ℓ.
In the seminal paper by Cai, Fürer and Immerman [15], the connection with logical indistinguishability was made.
Theorem 9.2**.**
Let G and H be two graphs of the same order. Then, G≡2WLH if and only if G≡C3H. ∎
We next show that ML(⋅,tr,∗,1,diag,⊙)-equivalence implies indistinguishability by the 2WL algorithm.
Proposition 9.1**.**
Let G and H be graphs of the same order. Then, G≡ML(⋅,tr,∗,1,diag,⊙)H implies that G≡2WLH.
Proof.
The overall proof is similar (both in terms of structure as strategy) to the proof of Proposition 7.2, but using indicator matrices (representing the edge partitions) instead of indicator vectors (which represented the vertex partitions), and by relying on the algorithm 2-Stab to compute the stable edge partition of a graph instead of algorithm GDCR (which computed the coarsest equitable partition). First, to simplify the construction of the expressions later on, we allow for
addition and scalar multiplication. It can be verified (see appendix) that G≡ML(⋅,tr,∗,1,diag,⊙)H implies
G≡ML(⋅,tr,∗,1,diag,⊙,+,×)H. We may thus indeed consider
ML(⋅,tr,∗,1,diag,⊙,+,×)
from now on.
The proof consists of the following two steps:
(a)
We first construct a number of expressions in ML(⋅,tr,∗,1,diag,⊙,+,×), denoted by stabcolc(X), for c∈C and C a set of colours.
The key property of these expressions is that when they are evaluated on the adjacency matrix AG of G,
stabcolc(AG), for c∈C, correspond to indicator matrices representing the stable edge partition of G.
(b)
The construction of the expressions stabcolc(X), for c∈C, depend on AG. As such, it is not guaranteed that stabcolc(AH), for c∈C, correspond to indicator matrices representing the stable edge partition of H. We show, however, when G≡ML(⋅,tr,∗,1,diag,⊙,+,×)H. holds, then stabcolc(AH), for c∈C, indeed correspond to indicator matrices representing the stable edge partition of H. To show this, we construct a number of sentences in
ML(⋅,tr,∗,1,diag,⊙,+,×).
Along the way, based on the construction of the expressions stabcolc(X), for c∈C, we show that G≡ML(⋅,tr,∗,1,diag,⊙,+,×)H implies that G≡2WLH holds.
(a) Compute the stable edge partition of a graph.
Given G=(V,E), let Π(G)={Ec1,…,Ecℓ} be its stable edge partition. We show that we can construct expressions stabcolci(X) in ML(⋅,tr,∗,1,diag,⊙,+,×), such that Eci=stabcolci(AG), for i=1,…,ℓ. The expressions are constructed by simulating the run of the algorithm 2-Stab on AG.
The initialisation step of 2-Stab is easy to simulate in ML(⋅,tr,∗,1,diag,⊙,+,×). Indeed, we simply consider expressions stabcol2(0)(X):=diag(1(X)); stabcol1(0)(X):=X; and finally, stabcol0(0)(X):=1(X)⋅(1(X))∗−X−diag(1(X)). Then, the indicator matrices stabcol0(0)(AG), stabcol1(0)(AG), and stabcol2(0)(AG) represent the initial partition Πχ0(G)={E0,E1,E2} corresponding to the initial colouring χ0.
Suppose now that after iteration i, the current set of colours is C and the colouring is χ:V×V→C. Assume, by induction, that we have expressions stabcolc(i)(X) in ML(⋅,tr,∗,1,diag,+,×,⊙), one for each c∈C, such that stabcolc(i)(AG) is an indicator matrix representing the part in the edge partition Πχ(G), induced by χ, for colour c. Given these, we next construct expressions for the refined partition computed by 2-Stab in the next iteration.
First, for each pair of colours (c,d) in C, we consider the expression
[TABLE]
On input AG, it is readily verified that Pc,d(i+1)(AG) is a matrix whose entry corresponding to vertices v1 and v2 holds the value pv1,v2c,d.
Let Pc,d(i+1) be the set of numbers occurring in Pc,d(i+1)(AG). For each value p in Pc,d(i+1), we now extract an indicator matrix indicating the positions in Pc,d(i+1)(AG) that hold value p.
This can be done using an expression indc,d,p(i+1)(X) which works in a similar way as #3deg(X) in Example 7.1, but uses the Schur-Hadamard product instead of products of diagonal matrices. The following example
illustrates the underlying idea (see also the Schur-Wielandt Principle [61] mentioned before).
Example 9.3**.**
Consider Pc,d=210032323 with Pc,d={0,1,2,3}. Suppose that we want to find all entries holding value 3. This can be computed, as follows:
[TABLE]
where 61=3(3−1)(3−2)1, just as in Example 7.1. ∎
More generally, to identify positions that hold a specific value in Pc,d(i+1)(AG), we consider the expression indc,d,p(i+1)(X) defined by
[TABLE]
It should be clear from Example 9.3 that indc,d,p(i+1)(AG) indeed results in the desired indicator matrix. We note that the expression
indc,d,p(i+1)(X) depends on the values in Pc,d(i+1) and hence also depends on AG.
Let C′ be the new set of colours assigned by 2-Stab(G) during the current iteration. As mentioned earlier, each colour c in C′ is in correspondence with L2(v1,v2) for some vertices v1 and v2. Let us pick a colour c in C′ and assume that it corresponds to
[TABLE]
We next use indc,d,p(i+1)(X) and the Schur-Hadamard product to identify all vertex pairs that are assigned colour c, as follows:
[TABLE]
In other words, we use the Schur-Hadamard product to simulate the “conjunction” of the binary matrices representing the vertex pairs (v1,v2) having non-zero structure constants pv1,v2ci,di, for i=1,…,s.
It is now easily verified that, on input AG, stabcolc(i+1)(AG) returns an indicator matrix in which the entries holding a 1 correspond precisely to the pairs (v1′,v2′)∈V×V such that L2(v1′,v2′)=L2(v1,v2) where L2(v1,v2) corresponds to colour c. In other words, stabcolc(i+1)(AG) represents the refined edge partition corresponding to the part associated with colour c. We do this for every colour in C′. Clearly, stabcolc(i+1)(AG), for c∈C′, represent the refined partition Πχ′(G) corresponding to χ′:V×V→C′.
We continue in this way until the colouring stabilises. i.e., no further colours are needed. We denote the final set of colours by C and by stabcolc(X), for c∈C, the
ML(⋅,tr,∗,1,diag,⊙,+,×) expressions computing the parts Ec in Π(G). The correctness of these expressions follows from the previous arguments and the correctness of the algorithm 2-Stab.
(b) Verifying that G≡2WLH.
Just as in the proof of Proposition 7.2, the expressions stabcolc(X) depend on AG since we explicitly used the values occurring in Pc,d(i)(AG) and the colours assigned to vertex pairs during each iteration i of the execution of 2-Stab on G. Let Π(H) be stable edge partition of H.
We next show that G≡ML(⋅,tr,∗,1,⊙,+,×)H implies that Π(H) consists of stabcolc(AH), for c∈C. Furthermore, we show that the number of ones in
stabcolc(AG) and stabcolc(AH) agree for all c∈C. Hence, G and H are indistinguishable by the 2WL algorithm.
The proof is by induction on the number of iterations of \textsc2−Stab(G) and \textsc2−Stab(H).
We denote by χG(i):V×V→CG(i) and χH(i):W×W→CH(i) the colourings used in the ith iteration of \textsc2−Stab(G) and \textsc2−Stab(H), respectively.
The induction hypothesis is that G≡ML(⋅,tr,∗,1,⊙,+,×)H implies that CG(i)=CH(i)=C(i) and furthermore that for each c∈C(i), stabcolc(i)(AH) is an indicator
matrix, and all stabcolc(i)(AH) together constitute the edge partition ΠχH(i)(H). Moreover, we show that for each c∈C(i), stabcolc(i)(AG) and stabcolc(i)(AH) have the same number of ones. This clearly suffices, for if this holds, stabcolc(AH), for c∈C, constitute Π(H) and stabcolc(AG) and stabcolc(AH) have the same number of ones, for all c∈C.
We start by verifying the hypothesis for the base case, i.e., when i=0.
Clearly, χG(0) and χH(0) use the same colours CG(0)=CH(0)=C(0)={0,1,2}.
By definition of the expressions stabcolc(0)(X), all stabcolc(0)(AH) together represent ΠχH(0)(H).
Moreover, by considering the sentences
[TABLE]
for c∈C(0), G≡ML(⋅,tr,∗,1,⊙,+,×)H implies that #onesc(0)(AG)=#onesc(0)(AH).
Hence, we may conclude that stabcolc(0)(AG) and stabcolc(0)(AH) have the same number of ones, as desired.
Suppose, by induction, that G≡ML(⋅,tr,∗,1,⊙,+,×)H implies that χG(i):V×V→CG(i) and χH(i):W×W→CH(i) with
CG(i)=CH(i)=C(i). Furthermore, the current edge partition ΠχH(i)(H) of H is represented by stabcolc(i)(AH), for c∈C(i). Furthermore,
for each c∈C(i), the number of ones in stabcolc(i)(AH) and stabcolc(i)(AG) agree.
As before, let Pc,d(i+1) be the set of values occurring in Pc,d(i+1)(AG) and consider the expressions indc,d,p(i+1)(X) for c,d∈C(i) and p∈Pc,d(i+1).
We show that indc,d,p(i+1)(AH) is a binary matrix as well containing the same number of ones as indc,d,p(i+1)(AG).
This implies that each value p∈Pc,d(i+1) occurs in Pc,d(i+1)(AH) and
moreover, it occurs the same number of times as in Pc,d(i+1)(AG). Hence, the set of values occurring in Pc,d(i+1)(AH) is the same as those occurring
in Pc,d(i+1)(AG).
To check that indc,d,p(i+1)(AH) is a binary matrix, we use the sentence
[TABLE]
This sentence will return [0], when given a real matrix as input, if and only if the input matrix is a binary matrix. We have seen a similar expression in the proof of Proposition 7.2.
Indeed, for a binary
matrix B, B⊙B=B and hence B⊙B−B=Z, where Z is the zero matrix. Since Z⊙Z=Z, binary(B)=1t⋅Z⋅1=[0]. For the converse,
assume that binary(B)=[0]. We observe that each entry in (B⊙B−B)⊙(B⊙B−B) is non-negative value.
Indeed, all entries are squares of real numbers. Hence, when binary(B)=[0], the sum of all these squared entries must be zero.
This implies that B⊙B−B=Z. This in turn implies that B can only
contain [math] or 1 as entries, since these are the only real values satisfying x2−x=0.
Hence, when G≡ML(⋅,tr,∗,1,⊙,+,×)H holds, then since all indc,d,p(i+1)(AG), for c,d∈C(i) and p∈Pc,d(i+1), are binary matrices,
[TABLE]
So indeed, indc,d,p(i+1)(AH) is a binary matrix as well.
The new colours in \textsc2−Stab(G) are assigned based on the structure lists L2(v1,v2). We show that for every unique structure list
L2(v1,v2) there is a pair of vertices w1,w2 in W such that L2(v1,v2)=L2(w1,w2). This implies that \textsc2−Stab(H)
will use the same colours for refining χH(i) as \textsc2−Stab(G) uses to refine χG(i). Hence, the revised colourings χG(i+1):V×V→CG(i+1)
and χH(i+1):W×W→CH(i+1) satisfy indeed that CG(i+1)=CH(i+1)=C(i+1).
Consider a structure list L2(v1,v2) and assume that it corresponds to a new colour c∈CG(i+1). We know that stabcolc(i+1)(AG) returns the indicator matrix indicating which vertex pairs in V×V have
this structure list (colour c). The expression stabcolc(i+1)(X) consists of the Schur-Hadamard product of indc,d,p(i+1)(X) for every (c,d,p) in L2(v1,v2).
We have shown above that indc,d,p(i+1)(AG) and indc,d,p(i+1)(AH) contain the same number of ones, meaning that there are vertex pairs (w1,w2)∈W×W
for which pw1,w2c,d=p=pv1,v2c,d. Furthermore, in a similar way as above, we can show that G≡ML(⋅,∗,tr,1,⊙,+,×)H implies that
stabcolc(i+1)(AH) is a binary matrix which consists of the same number of ones as stabcolc(i+1)(AG). So, \textsc2−Stab(H) needs the
same set of colours CG(i+1) as \textsc2−Stab(G) in the refinement phase. Hence, we can take CG(i+1)=CH(i+1)=C(i+1).
By construction, stabcolc(i+1)(AH) and stabcolc′(i+1)(AH) do not have a common entry holding value 1, for each distinct pair of colours c,c′∈C(i+1).
We note that the number of entries holding value 1 in all stabcolc(i+1(AH) combined sum up n2. Indeed, we know that this holds for stabcolc(i+1)(AG) and we have
just shown that stabcolc(i+1))(AH) consists of the same number of ones as stabcolc(i+1)(AG). Hence, stabcolc(i+1)(AH) also represent
a partition of W×W, i.e., the partition ΠχH(i+1)(H) and the induction hypothesis is satisfied.
∎
9.3 Main result
We are now ready to show the main result of this section.
Theorem 9.4**.**
Let G and H be two graphs of the same order, then G≡ML(⋅,tr,∗,1,diag,⊙)H if and only if G≡MATLANGH if and only if G≡C3H.
Proof.
We show that G≡ML(⋅,tr,∗,1,diag,⊙)H implies G≡C3H, and that
G≡C3H implies G≡MATLANGH. Since ML(⋅,tr,∗,1,diag,⊙) is a smaller fragment than MATLANG, G≡MATLANGH clearly implies G≡ML(⋅,tr,∗,1,diag,⊙)H, resulting in the theorem.
Let us assume that G≡ML(⋅,tr,∗,1,diag,⊙)H holds. Then, the previous proposition implies that G≡2WLH.
Combined with Theorem 9.2, this implies that G≡C3H. Next, we assume that G≡C3H holds. We show that this implies that G≡MATLANGH. We here rely on the connection between MATLANG and three-variable logics [11], which we first recall.
In Proposition 4.2 in Brijder et al. [11] it was shown that for every sentence e(X) in MATLANG there exists an equivalent formula φe(z) in the relational calculus with aggregates which uses only three “base variables”. We will
not recall the syntax of this calculus formally (see [54] for a full definition) but only recall that in this calculus, we have base variables and numerical variables. Base variables can be bound to base columns of relations, and compared for equality. Numerical variables can be bound to numerical columns, and can be equated to function applications and aggregates.
The free variable z in φe(z) is a numeric variable since a scalar is returned by e(X).
We now make the connection between matrices, on which MATLANG expressions are evaluated, and such typed relations, on which calculus expressions are evaluated. More specifically, a matrix A is encoded as a ternary relation Rel(A) where two base columns are reserved for the indices of the matrix and the numerical column holds the value in each entry (vectors and scalars are represented analogously).
It is now understood that the equivalence of e(X) and φe(z) means that e(AG) and the evaluation of φe(z) on Rel(AG) results in the same scalar. Let c=e(AG)∈C and consider the calculus sentence ψe:=∃zφe(z)∧z=c. Following the arguments in the proof of Proposition 4.4 in [11], which in turn rely on standard
translation techniques (see e.g., [44, 54]), one can show that ψe can be equivalently expressed by a sentence ψe′ in C∞ω3 [59], i.e., in infinitary counting logic with three distinct (untyped) variables over binary relations. These binary relations encode graphs in a standard way by simply storing the edge relation.
It is known that G≡C∞ω3H if and only if G≡C3H [43]. By assumption G≡C3H and hence G≡C∞ω3H. This implies that ψe′(G)=ψe′(H) since ψe′ is a sentence in C∞ω3. Hence, also ψe evaluates to true on both Rel(AG) and Rel(AH),
and φe(z) returns the value c on both Rel(AG) and Rel(AH). As a consequence, also e(AH)=c and e(AG)=e(AH). Since this argument works for any MATLANG sentence e(X), we have that G≡MATLANGH. ∎
The results by Dell et al. [27] also tell that G≡MATLANGH if and only if HOMF(G)=HOMF(H) where
F consists of all graphs of tree-width at most two.
We conclude by providing an algebraic characterisation of MATLANG-equivalence based on a result by Dawar et al. [25]. To state this result, we need the notion of
coherent algebra (see e.g., [30]). The coherent algebraC(AG) associated with AG is the smallest complex matrix algebra containing AG, I, and J and which is closed under the Schur-Hadamard product. The coherent algebra C(AH) associated with AH is defined similarly. The algebras C(AG) and C(AH) are said to be algebraically isomorphic if there is bijection :C(AG)→C(AH) which is
an algebra morphism which in addition satisfies: (J)=J, (A∗)=((A))∗ and (A⊙B)=(A)⊙(B), for all matrices A,B∈C(AG).
Proposition 9.2** (Proposition 7 in Dawar et al. [25]).**
Let G and H be two graphs of the same order. Then, G≡C3H if and only if there exists an algebraic isomorphism :C(AG)→C(AH) such that (AG)=(AH). ∎
This correspondence can be made a bit more precise and in line with our previous characterisations.
Proposition 9.3**.**
Let G and H be two graphs of the same order, then G≡MATLANGH if and only if there exists an orthogonal matrix O such that Ec⋅O=O⋅Fc, for c∈C, where
Ec and Fc, for c∈C, constitute the stable edge partitions Π(G) and Π(H) of G and H, respectively. (Here, C denotes the set of colours used by the colourings that induce
the partitions).
Proof.
We know from Proposition 9.1 that G≡MATLANGH implies that G≡2WLH. Moreover, we can compute Π(G) and Π(H) by means of the expressions stabcolc(X) in MATLANG. Let C={c1,…,cℓ} be the set of colours used in these partitions. Just as in the proof of Theorem 7.4, we consider sentences
e_{w}(X):=\mathsf{tr}\bigl{(}w(\mathsf{stabcol}_{c_{1}}(X),\ldots,\allowbreak\mathsf{stabcol}_{c_{\ell}}(X))\bigr{)} for some word w over ℓ variables. Then, G≡MATLANGH implies that
ew(AG)=ew(AH) for any such word w, and thus by the real version of Specht’s Theorem, there exists an orthogonal matrix O such that stabcolc(AG)⋅O=O⋅stabcolc(AH) for all c∈C, as desired. In the application of Specht’s Theorem it is crucial that Π(G) and Π(H) are closed under transposition. This known to hold, i.e., for every part Ec in Π(G) there is a part Ec′ such that Ect=Ec′. This property also holds for Π(H) (see e.g., [8]).
For the converse, suppose that there exists an orthogonal matrix O such that Ec⋅O=O⋅Fc, for c∈C. We note that this implies that AG⋅O=O⋅AH since AG=∑c∈DEc and AH=∑c∈DFc for some subset of colours D of C. This follows the fact that the 2WL algorithm refines the initial colouring, in which edges are coloured differently than non-edges.
So, a colour used for an edge in G can only be used for an edge in H, and vice versa.
Moreover, it is known that
the binary matrices in Π(G) and Π(H) form a basis for C(AG) and C(AH), respectively.
If we now consider :C(AG)→C(AH):A↦O⋅A⋅Ot, then this is known to be an algebraic isomorphism between C(AG) and C(AH) [30]. Hence, by Proposition 9.2, G≡C3H and thus also
G≡MATLANGH by Theorem 9.4.∎
Remark 9.5**.**
The orthogonal matrix O in the statement of Proposition 9.3 can be taken to be compatible with the coarsest equitable partitions of G and H, that witness that G and H have a common equitable partition. This is in agreement with Theorem 7.4. This follows from the fact that there is a subset K of colours such that I=∑c∈KEc=∑c∈KFc [8]. Furthermore, the diagonal matrices Ec, for c∈K, correspond to diag(1Vc) for the coarsest
equitable partition V={Vc∣c∈K} of G. Similarly, for c∈K, Fc=diag(1Wc) correspond to the coarsest equitable partition W={Wc∣c∈K} of H [8].
Remark 9.6**.**
The proof of Proposition 9.3 relied on results by Brijder et al. [11] and Dawar et al. [25] in which connections with C3-equivalence were made. A direct proof of Proposition 9.3 is possible. Indeed, it suffices to show that O-conjugation, for an orthogonal matrix O such that Ec⋅O=O⋅Fc holds for each colour c∈C, is preserved by all operations in MATLANG, including arbitrary pointwise functions on matrices.
We do not detail this further in this paper in order to keep the paper of reasonably length (the proof consists of a long case analysis in which all previous conjugation-preserving conditions need to be verified in the context of stable edge partitions). The crucial ingredient in all this is that one can verify that for any expression e(X) in MATLANG, such that e(AG) returns a matrix,
we can write e(AG)=∑c∈Cac×Ec and e(AH)=∑c∈Cac×Fc. This is generalization ML(L)-vectors being constant on equitable partitions, but now for ML(L)-matrices being constant on stable edge partitions. The ability to rewrite e(AG) (and e(AH)) in terms of the indicator matrices allows to show, e.g., that O-conjugation is preserved by the Schur-Hadamard product and, more generally, by any pointwise function application on matrices.
10 Conclusion
We have characterised ML(L)-equivalence for undirected graphs and identified what additional distinguishing power each of the operations in MATLANG has.
Some of the results generalise to directed graphs (with asymmetric adjacency matrices) or even arbitrary matrices. This is explored in an upcoming paper [34].
The extension to the case when queries can have multiple inputs is wide open.
Of interest may also be to connect ML(L)-equivalence to fragments of first-order logic (without counting). A possible line of attack could be to work over the boolean semiring instead of over the complex numbers (see Grohe and Otto [39] for a similar approach). More general semirings could open the way for modelling and querying labeled graphs using matrix query languages (see also [13]).
Another question is which additional linear algebra operations should be added to the matrix language MATLANG such that Ck-equivalence can be captured, for k≥4. We refer to [4, 39, 57] characterisation of Ck-equivalence in terms of solutions of linear systems of equations, which may serve as inspiration.
Finally, connections between MATLANG and rank logics, as studied in the context of the descriptive complexity of linear algebra [23, 22, 24, 37, 40, 45], are worth exploring.
**Acknowledgement.**The author is grateful to Joeri Rammelaere (and his Python skills) for computing the numerical quantities of the example graphs used in this paper.
Let ML(L) be any matrix query language fragment and let G and H be graphs of the same order.
Consider expressions e1(X) and e2(X) in ML(L). If ei(AG) and ei(AH) are T-similar, for i=1,2, for an arbitrary matrix T, then e1(AG)⋅e2(AG) is also T-similar to e1(AH)⋅e2(AH).
Proof.
To show this lemma, we distinguish between the following cases, depending on the dimensions of e1(AG) and e2(AG) (or equivalently, the dimensions of e1(AH) and e2(AH)). Let e(X):=e1(X)⋅e2(X). Let n be the order of G (and H).
•
(n×n,n×n): e1(AG) and e2(AG) are of dimension n×n. By assumption, e1(AG)⋅T=T⋅e1(AH) and e2(AG)⋅T=T⋅e2(AH). Hence,
[TABLE]
•
(n×n,n×1): e1(AG) is of dimension n×n and e2(AG) is of dimension n×1. By assumption, e1(AG)⋅T=T⋅e1(AH) and e2(AG)=T⋅e2(AH). Hence,
[TABLE]
•
(n×1,1×n): e1(AG) is of dimension n×1 and e2(AG) is of dimension 1×n. By assumption, e1(AG)=T⋅e1(AH) and e2(AG)⋅T=e2(AH). Hence,
[TABLE]
•
(n×1,1×1): e1(AG) is of dimension n×1 and e2(AG) is of dimension 1×1. By assumption, e1(AG)=T⋅e1(AH) and e2(AG)=e2(AH). Hence,
[TABLE]
•
(1×n,n×n): e1(AG) is of dimension 1×n and e2(AG) is of dimension n×n. By assumption, e1(AG)⋅T=e1(AH) and e2(AG)⋅T=T⋅e2(AH). Hence,
[TABLE]
•
(1×n,n×1): e1(AG) is of dimension 1×n and e2(AG) is of dimension n×1. By assumption, e1(AG)⋅T=e1(AH) and e2(AG)=T⋅e2(AH). Hence,
[TABLE]
•
(1×1,1×n): e1(AG) is of dimension 1×1 and e2(AG) is of dimension 1×n. By assumption, e1(AG)=e1(AH) and e2(AG)⋅T=e2(AH). Hence,
[TABLE]
•
(1×1,1×1): e1(A) and e2(A) are of dimension 1×1. By assumption, e1(AG)=e1(AH) and e2(AG)=e2(AH). Hence, e(AG)=e1(AG)⋅e2(AG)=e1(AH)⋅e2(AH)=e(AH).
This concludes the proof.
∎
Continuation of the proofs of Proposition 7.2 and Theorems 8.3 and 9.1
In all three proofs we relied on the presence of addition and scalar multiplication to compute either equitable partitions or stable edge partitions. Since addition and scalar multiplication are
used in the proofs before the proper conjugacy notion was identified, we cannot simply rely on Lemma 5.3. We therefore show that when L is either {⋅,∗,1,diag}, {⋅,tr,∗,diag} (for Proposition 7.2), {⋅,tr,∗,1,⊙v} (Theorem 8.3) or
{⋅,tr,∗,1,diag,⊙} (Theorem 9.1),
that G≡ML(L)H implies G≡ML(L+)H, where
L+=L∪{+,×}.
We show this by verifying that any expression e(X) in ML(L+) can be equivalently written as a linear combination of expressions in ML(L). We denote equivalence by ≡ and
e(X)≡e′(X) means that e(A)=e′(A) for all matrices A.
We verify our claim by induction on the structure of expressions.
(base case) Let e(X):=X. This already has the desired form.
(matrix multiplication) Let e(X):=e1(X)⋅e2(X). By induction we have that e1(X)≡∑i=1pai×ei1(X) and
e2(X)≡∑i=1qbi×ei2(X). Hence, e(X)≡∑i=1p∑j=1q(ai×bi)×(ei1(X)⋅ej2(X)).
(complex conjugate transposition) Let e(X):=(e1(X))∗. By induction, e1(X)≡∑i=1pai×ei1(X). Then, e(X)≡∑i=1paˉi×(ei(X))∗.
(trace) Let e(X):=tr(e1(X)). By induction,
e1(X)≡∑i=1pai×ei1(X). Then, e(X)≡∑i=1pai×tr(ei(X)).
(ones-vector) Let e(X):=1(e1(X)). By induction,
e1(X)≡∑i=1pai×ei1(X). Then, e(X)≡1(e11(X)).
(diag) Let e(X):=diag(e1(X)).
By induction,
e1(X)≡∑i=1pai×ei1(X). Then, e(X)≡∑i=1pai×diag(ei1(X)).
(pointwise vector product) Let e(X):=e1(X)⊙ve2(X). By induction we have that e1(X)≡∑i=1pai×ei1(X) and
e2(X)≡∑i=1qbi×ei2(X). Hence, e(X)≡∑i=1p∑j=1q(ai×bi)×(ei1(X)⊙vej2(X)).
(Schur-Hadamard)
(pointwise vector product) Let e(X):=e1(X)⊙e2(X). By induction we have that e1(X)≡∑i=1pai×ei1(X) and
e2(X)≡∑i=1qbi×ei2(X). Hence, e(X)≡∑i=1p∑j=1q(ai×bi)×(ei1(X)⊙ej2(X)).
ML(⋅,∗,tr,1,diag,+,×,applys[f],f∈Ω)-vectors are constant on equitable partitions.
Proof.
Let L# denote {⋅,∗,tr,1,diag,+,×,applys[f],f∈Ω}. Consider a graph G of order n with equitable partition V={V1,…,Vℓ}. As before, let 1V1,…,1Vℓ be the corresponding indicator vectors. We will show that for any expression e(X)∈ML(L#) such that e(AG) is an n×1-vector, e(AG) can be uniquely written in the form ∑i=1ℓai×1Vi for scalars ai∈C.
We show, by induction on the structure of expressions in ML(L#), that the following properties hold;
(a)
if e(AG) returns an n×n-matrix, then for any pair i,j=1,…,ℓ there exists a scalars aij,bij∈C such that
[TABLE]
2. (b)
if e(AG) returns an n×1-vector, then for any i=1,…,ℓ, there exists a scalar ai∈C such that
[TABLE]
Clearly, if (b) holds for every i=1,…,ℓ, then, e(AG)=∑i=1ℓai×1Vi because I=∑i=1ℓdiag(1Vi). We remark these properties can be seen as generalization of the known fact that the vector space spanned by indicator vectors of an equitable partition of G is invariant under multiplication by AG (See e.g., Lemma 5.2 in [16]). That is, for any linear combination v=∑i=1ℓai×1Vi we have that A⋅v=∑i=1ℓbi×1Vi. In our setting, (a) and (b) imply that e(AG)⋅v is again a linear combination of indicator vectors, when e(AG) returns an n×n-matrix. We next verify properties (a) and (b). We often use that I=∑i=1ℓdiag(1Vi) and 1=∑i=1ℓ1Vi.
(base case) Let e(X):=X. The required property is simply a restatement of the being equitable. That is,
[TABLE]
for an arbitrary vertex v∈Vi. So, we can take aij=deg(v,Vj). Similarly, because we AG is a symmetric matrix,
[TABLE]
for an arbitrary vertex v∈Vi. So, we can take aij=deg(v,Vj).
Below, for condition (a) we only verify that diag(1Vi)⋅e(AG)⋅1Vj=aij×1Vi holds. The verification of 1Vjt⋅e(AG)⋅diag(1Vi)=bij×1Vit is entirely similar.
(multiplication) Let e(X):=e1(X)⋅e2(X). We distinguish between a number of cases, depending on the dimensions of e1(AG) and e2(AG). We first check the cases when e(AG) returns an n×n-matrix and need to show that property (a) holds.
•
(n×n,n×n): e1(AG) and e2(AG) are of dimension n×n. By induction, diag(1Vi)⋅e1(AG)⋅1Vj=aij×1Vj and
diag(1Vi)⋅e2(AG)⋅1Vj=bij×1Vi.
Then, diag(1Vi)⋅e(AG)⋅1Vj is equal to
[TABLE]
as desired.
•
(n×1,1×n): e1(AG) is of dimension n×1 and e2(AG) is of dimension 1×n. By induction we have that diag(1Vi)⋅e1(AG)=ai×1Vi and diag(1Vi)⋅(e2(AG))t=bi×1Vi. Hence, diag(1Vi)⋅e(AG)⋅1Vj is equal to
[TABLE]
as desired.
Here we used that 1Vkt⋅1Vj is either [math], in case that k=j, or ∣Vj∣ in case that j=k.
We next check that condition (b) holds when e(AG) returns an n×1-vector.
•
(n×n,n×1): e1(AG) is of dimension n×n and e2(AG) is of dimension n×1. By induction, we have that diag(1Vi)⋅e1(AG)⋅1Vj=aij×1Vi and
diag(1Vi)⋅e2(AG)=bi×1Vi. Hence, diag(1Vi)⋅e(AG) is equal to
[TABLE]
as desired.
•
(n×1,1×1): e1(AG) is of dimension n×1 and e2(AG) is of dimension 1×1. By induction we have that diag(1Vi)⋅e1(AG)=ai×1Vi and e2(AG)=b∈C. Hence,
[TABLE]
as desired.
(ones vector) e(X):=1(e1(X)). We only need to consider the case when e1(AG) is an n×n-matrix or n×1-vector. In both cases, it suffices to observe that 1=∑i=1ℓ1Vii. Indeed,
[TABLE]
(conjugate transpose) e(X):=(e1(X))∗. If e1(AG) returns a 1×n-vector, then diag(1Vi)⋅(e1(AG))t=ai×1Vi. Hence, diag(1Vi)⋅e1(AG)=ai∗×1Vi. If e1(AG) returns an n×n-matrix, then by induction, 1Vjt⋅e1(AG)⋅diag(1Vi)=bij×1Vit. Hence,
[TABLE]
as desired.
(diag operation) e(X):=diag(e1(X)) where e1(AG) is an n×1-vector. By induction, diag(1Vi)⋅e1(AG)=ai×1Vi. Hence, in view of the linearity of the diagonal operation,
[TABLE]
since diag(1Vk)⋅1Vj is 1Vj when k=j and the zero vector otherwise.
(addition) e(X):=e1(X)+e2(X). Clearly, when condition (a) or (b) hold for e1(AG) and e2(AG), they remain to hold for e(AG).
(scalar multiplication) e(X):=a×e1(X). Clearly, when condition (a) or (b) hold for e1(AG), they remain to hold for e(AG).
(trace) e(X):=tr(e1(X)). Such sub-expressions do not return matrices or vectors.
(pointwise function applications) e(X):=applys[f](e1(X),…,ep(X)) where each ei(X) is a sentence. Again, such sub-expressions do not return matrices or vectors.
∎
ML(⋅,∗,tr,1,⊙v,diag,+,×,applys[f],f∈Ω)-vectors are constant on equitable partitions
Proof.
Given that we verified this property of all operations except for ⊙v in the proof of Proposition 7.4, we only need to verify that ⊙v can be added to the list of supported operations. We use the same induction hypotheses as in the proof of Proposition 7.4 and verify that these hypotheses remain to hold for ⊙v:
(pointwise vector multiplication) e(X):=e1(X)⊙ve2(X) where e1(X) and e2(X) return vectors. By induction we have that diag(1Vi)⋅e1(AG)=ai×1Vi and diag(1Vi)⋅e2(AG)=bi×1Vi. As a consequence,
[TABLE]
because 1Vi⊙v1Vj) is either 1Vi when i=j, or the zero vector when i=j.
∎
In the proof in the main body of the paper we left open the verification that (1Vi⋅1Vit)⋅O=O⋅(1Wi⋅1Wit), for i=1,…,ℓ, implies that O preserves the coarsest equitable partitions of G and H. In particular, we need to verify that 1Vi=O⋅1Wi, for i=1,…,ℓ. This can be easily shown, just as in the proof of Theorem 7.4 (based on Lemma 4 in Thüne [68]), in which we verified that J⋅O=O⋅J implies that 1=O⋅1.
First, we observe that (1Vi⋅1Vit)⋅O⋅1Wi=1Vi⋅(1Vit⋅O⋅1Wi)=αi×1Vi with αi=1Vit⋅O⋅1Wi and (1Vi⋅1Vit)⋅O⋅1Wi=O⋅(1Wi⋅1Wit)⋅1Wi=(1Wit⋅1Wi)×O⋅1Wi. In other words, O⋅1Wi=niαi×1Vi where 1Wit⋅1Wi=∣Wi∣=ni. Furthermore, because 1Vit⋅Ot⋅1Wi is a scalar, 1Wit⋅Ot⋅1Vi=(1Vit⋅O⋅1Wi)t=1Vit⋅O⋅1Wi=αi. We next show that α=±ni. Indeed, since O is an orthogonal matrix
[TABLE]
and thus αi2=ni2 or αi=±ni. Hence, O⋅1Wi=±1Vi. We note that 1=∑i=1ℓ1Vi=∑i=1ℓ1Wi. We now argue that either 1Vi=O⋅1Wi for all i=1,…,ℓ, or −1Vi=O⋅1Wi for all i=1,…,ℓ. Indeed, suppose that we have 1Vi=O⋅1Wi for i∈K⊂{1,…,ℓ} and −1Vi=O⋅1Wi for i∈Kˉ={1,…,ℓ}∖K, for some non-empty subset K of {1,…,ℓ}. Then \sum_{i\in K}\mathbb{1}_{V_{i}}=O\mskip 2.0mu{\cdot}\mskip 2.0mu\bigl{(}\sum_{i\in K}\mathbb{1}_{W_{i}}\bigr{)} and hence since ∑i∈Kˉ1Vi=1−∑i∈K1Vi and ∑i∈Kˉ1Wi=1−∑i∈K1Wi,
[TABLE]
This contradicts that -\sum_{i\in\bar{K}}\mathbb{1}_{V_{i}}=O\mskip 2.0mu{\cdot}\mskip 2.0mu\bigl{(}\sum_{i\in\bar{K}}\mathbb{1}_{W_{i}}\bigr{)}. Hence, when 1Vi=O⋅1Wi for all i=1,…,ℓ, O satisfies the desired property already. Otherwise, when −1Vi=O⋅1Wi for all i=1,…,ℓ, we simply replace O by (−1)×O to obtain that O⋅1Wi=1Vi. This rescaling does not impact that AG⋅O=O⋅AH and we can thus indeed conclude that O preserves the coarsest equitable partitions of G and H. ∎
Bibliography73
The reference list from the paper itself. Each links out to its DOI / PubMed record.
1[1] Noga Alon, Raphael Yuster, and Uri Zwick. Finding and counting given length cycles. Algorithmica , 17(3):209–223, 1997. https://doi.org/10.1007/BF 02523189 . · doi ↗
2[2] Renzo Angles, Marcelo Arenas, Pablo Barceló, Aidan Hogan, Juan Reutter, and Domagoj Vrgoč. Foundations of modern query languages for graph databases. ACM Comput. Surv. , 50(5):68:1–68:40, 2017. http://doi.acm.org/10.1145/3104031 .
3[3] Vikraman Arvind, Frank Fuhlbrück, Johannes Köbler, and Oleg Verbitsky. On weisfeiler-leman invariance: Subgraph counts and related graph properties. Co RR , abs/1811.04801, 2018. http://arxiv.org/abs/1811.04801 .
4[4] Albert Atserias and Elitza N. Maneva. Sherali-Adams relaxations and indistinguishability in counting logics. SIAM J. Comput. , 42(1):112–137, 2013. https://doi.org/10.1137/120867834 . · doi ↗
5[5] Sheldon Axler. Linear Algebra Done Right . Springer, third edition, 2015. https://doi.org/10.1007/978-3-319-11080-6 . · doi ↗
6[6] Pablo Barceló. Querying graph databases. In Proceedings of the 32nd ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems , PODS, pages 175–188, 2013. http://doi.acm.org/10.1145/2463664.2465216 .
7[7] Pablo Barceló, Nelson Higuera, Jorge Pérez, and Bernardo Subercaseaux. On the expressiveness of LARA: A unified language for linear and relational algebra. Co RR , 2019. URL: http://arxiv.org/abs/1909.11693 .
8[8] Oliver Bastert. Stabilization procedures and applications . Ph D thesis, Technical University Munich, Germany, 2001. http://nbn-resolving.de/urn:nbn:de:bvb:91-diss 2002070500045 .