Expressive Power of Deep Homomorphism Networks over Relational Databases

Moritz Schönherr, Balder ten Cate, Maurice Funk, Benny Kimelfeld, Carsten Lutz, Arie Soeteman

TL;DR

Standard Graph Neural Networks (GNNs) are famously limited by the 1-Weisfeiler-Leman test, making them "blind" to common structures like triangles and cycles. This paper advocates for Deep Homomorphism Networks (DHNs), a more powerful architecture that counts structural patterns (homomorphisms) to learn over relational databases. By mapping DHNs to specific fragments of first-order logic, the authors provide a rigorous theoretical framework for understanding exactly what these networks can learn and how they relate to SQL queries.

What Problem Does This Paper Address?

While GNNs are powerful, they have a "tree-shaped" bias. They struggle to distinguish between graphs that look the same locally but differ in global structure (like a collection of triangles vs. a single large cycle). This is a major hurdle for relational databases, where the most important queries—Conjunctive Queries (CQs)—are essentially based on finding homomorphisms.

The authors address two main gaps:

  1. Expressivity: How do we build a neural architecture that naturally handles relational data and surpasses the structural limitations of standard message-passing GNNs?
  2. Theoretical Grounding: Can we precisely define the "intelligence" of these networks using the language of logic? If we know a DHN is equivalent to a specific logical fragment, we can use decades of database theory to analyze the model's behavior.

Methods

The paper focuses on Deep Homomorphism Networks (DHNs). Unlike standard GNNs that pass messages along edges, DHNs use "homomorphism queries." These queries count how many times a small pattern graph (like a triangle) can be mapped into the larger database.

The authors analyze DHNs based on their aggregation functions:

  • Max-DHNs: Use "max" to combine signals. The authors prove these are equivalent to the Unary Negation fragment of First-Order Logic (UNFO).
  • Sum-DHNs: Use "sum" to count patterns. These are shown to be more powerful, equivalent to logic with counting quantifiers (UNFOC) on bounded-degree graphs.
  • Mean-DHNs: Use "averaging," relating them to logic with ratio quantifiers.

They also introduce Deep Embedding Networks (DENs), a variation where homomorphisms are replaced by embeddings (injective mappings), and prove that for "sum" aggregation, DHNs and DENs have identical expressive power.

Datasets

The authors used two synthetic benchmarks designed to test specific structural recognition capabilities:

  • Local Transitivity Dataset: A directed graph task where the model must identify if a vertex $v$ satisfies a transitivity property (if $v \to u_1$ and $u_1 \to u_2$, then $v \to u_2$).
  • Sun Property Dataset: An undirected graph task where a vertex must be part of a 6-cycle where every vertex in that cycle has a neighbor of degree 1. This "sun" shape is impossible for standard GNNs to detect reliably.

The DHNs were compared against standard implementations of GCN, GraphSAGE, and GIN.

Key Insights and Ideas

  • The Logic-Neural Bridge: The most significant "aha moment" is the formal proof that DHNs are neural versions of specific logical fragments. This means that designing a DHN is, in a sense, like writing a differentiable SQL query.
  • Static Analysis is Possible: Because DHNs map to logic, we can solve "static analysis" problems. For example, we can algorithmically determine if a DHN is "empty" (will never fire for any input) or if one DHN is "subsumed" by another (logically more general).
  • Surpassing Feature Augmentation: A common trick is to give GNNs "homomorphism counts" as initial features. This paper proves that DHNs are strictly more expressive than these augmented GNNs because DHNs can use those counts across multiple layers of non-linear processing.
  • The "Sandwich" Result: The authors couldn't find a perfect logical match for Sum-DHNs on unrestricted graphs, so they "sandwiched" them between a new logic they defined (UQAFO) and a highly expressive counting logic (HML+C).

Key Results

  • Performance: In the "Sun Property" test, sum-DHNs achieved a perfect 1.00 F1 score, while the best standard GNN (GIN) managed only 0.68. Even GIN augmented with homomorphism counts only reached 0.88.
  • Local Transitivity: sum-DHNs reached 0.98 F1, significantly outperforming max-DHNs (0.83) and standard GCNs (0.76).
  • Decidability: The authors proved that the "emptiness problem" is decidable for max-DHNs and for connected sum-DHNs on bounded-degree graphs, but undecidable for sum-DHNs in the general case.

Limitations and Future Work

  • Pattern Selection: Currently, the "patterns" (homomorphism queries) used by the DHN must be selected manually or via heuristics. The authors note that principled, automated pattern selection is a key area for future research.
  • Computational Complexity: While some analysis problems are decidable, their worst-case complexity is high (e.g., CONEXPTIME-complete), which may limit practical application for very large-scale model verification.
  • Implementation: The current implementation is a "proof of concept" using naive backtracking for homomorphism counting. Integrating DHNs more tightly into optimized database management systems (DBMS) is a promising next step.

Summary updated

BibTeX
@inproceedings{schonherr2026expressive,
  author = {Moritz Schönherr and Balder ten Cate and Maurice Funk and Benny Kimelfeld and Carsten Lutz and Arie Soeteman},
  title = {{Expressive Power of Deep Homomorphism Networks over Relational Databases}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=PUkMW1q30n},
}
Figure