Proofs: Weisfeiler-Leman algorithm
These are the human proofs of Weisfeiler-Leman algorithm, at full length.
Color refinement terminates, is isomorphism-invariant, and returns the coarsest equitable refinement full
This proof shows: correctness, termination.
Setting. Let be a finite simple undirected graph with vertices and an initial coloring . In WL-TEST, is the disjoint union and . Write for the set of neighbors of , and for a coloring write for the multiset of neighbor colors. A coloring refines when implies . Let be the coloring held after executions of L6, with the ranked coloring of L1.
Lemma 1 (refinement). For every , refines .
Proof. By L3 and L4, holds exactly when . The first component of is , so equal signatures give .
Lemma 2 (termination). The loop runs at most times, and on return the coloring satisfies: for all , implies .
Proof. By Lemma 1 the partition of refines that of , so it has at least as many classes, and it has exactly as many only when the two partitions are equal. L5 returns as soon as the number of classes does not grow. The number of classes is between 1 and , so after at most iterations it stops growing. When L5 returns , the partitions of and are equal. If then , so , and the second components give equal multisets of neighbor colors under . The sorted list in L3 represents the multiset exactly.
A coloring with the property of Lemma 2 is equitable: two vertices of the same color have, for each color , the same number of neighbors of color .
Lemma 3 (invariance). Let be a bijection with and for all . Then for all and all .
Proof. By induction on . The case is the hypothesis, since L1 applies the same rank map to equal values. Assume the claim for . The map sends bijectively onto , so
With , this gives in round , and L4 gives both the same rank.
Theorem 1 (soundness of WL-TEST). If WL-TEST returns "not isomorphic", then there is no isomorphism from to that keeps the initial colors.
Proof. Assume is such an isomorphism. Define on by for and for . Then is a bijection of , it maps edges of to edges and non-edges to non-edges (edges of go to edges of and back, and there are no edges between the two parts), and it keeps . By Lemma 3 the returned coloring satisfies for . Since is a bijection from onto , the multisets and are equal, so L8 does not report "not isomorphic".
Theorem 2 (coarsest equitable refinement). The returned coloring is equitable, refines , and is refined by every equitable coloring that refines . Hence its partition is the unique coarsest equitable partition that refines .
Proof. Equitability is Lemma 2, and refines by Lemma 1 and transitivity. Let be equitable and refine . We show by induction on that refines . For this is the hypothesis. Assume refines , and let . Then . Since is equitable, for each -color the vertices and have the same number of neighbors of color . Each -class is a union of -classes, because refines . Summing over the -classes inside a -class , and have the same number of neighbors of -color , for every . So their multisets of neighbor colors under are equal, in round , and . So refines , and in particular refines the returned . If two equitable partitions both refine and are both refined by every such partition, each refines the other, so they are equal.
Lemma 2 gives termination, Theorem 1 gives the correctness of every "not isomorphic" answer, and Theorem 2 shows that the result does not depend on the order in which an implementation splits cells, so any correct partition refinement computes the same stable partition.