SHACL Validation in the Presence of Ontologies: Semantics and Rewriting Techniques

Anouk Oudshoorn, Magdalena Ortiz, Mantas SimkusarXiv 2025 · DOI

TL;DR

This paper bridges the semantic gap between OWL ontologies (which operate under the open-world assumption) and SHACL constraints (which assume a closed world) by introducing a validation framework based on "austere canonical models." The authors provide a query rewriting technique for the rich description logic $Horn-\mathcal{ALCHIQ}$, allowing standard SHACL engines to validate incomplete data graphs by compiling ontological rules directly into modified constraints.

What Problem Does This Paper Address?

In the world of Semantic Web standards, managing RDF data often requires balancing two powerful but fundamentally opposed paradigms:

  1. Web Ontology Language (OWL), which uses the Open-World Assumption (OWA) to infer missing facts from incomplete data.
  2. Shape Constraint Language (SHACL), a data-validation language that uses the Closed-World Assumption (CWA) to check whether a dataset conforms to specific structural constraints.

Combining them is highly desirable—for instance, validating a dataset while taking implied ontological facts into account. However, their opposing views on "missing data" create a massive semantic gap. If an ontology implies the existence of an anonymous node (e.g., "Every PetOwner must have a pet"), a standard naive database chase will generate a dummy node. If a SHACL constraint checks whether a person only owns hamsters, this dummy node will cause the validation to fail because it lacks a Hamster label.

This paper addresses how to define a clean, intuitive semantics for SHACL validation in the presence of ontologies and how to practically compute it without generating infinite or redundant data structures.

Fig. 2. Result of oblivious or Skolem chase (left) and austere canonical model (right). We use hasWP and hasP as a shorthand for hasWingedPet and hasPet.

Methods

The authors tackle the problem through a combination of novel semantics and algorithmic rewriting:

  • Austere Canonical Models: To handle SHACL features like negation safely, the authors introduce a semantics based on locally minimal universal models. This model satisfies ontology axioms by introducing as few anonymous successors as possible, effectively creating a "core" model in the database sense.
  • Good Successor Configuration: They define a data-independent, finite representation that determines exactly what fresh successor individuals and roles are needed at any point in the model to satisfy the ontology's existential rules.
  • SHACL Rewriting Algorithm: Instead of materializing a potentially infinite canonical model, the authors develop a compilation technique. It takes the ontology rules (TBox) and a set of stratified SHACL constraints (which allow recursion and negation but restrict their interaction) and compiles them into a new, expanded set of standard SHACL constraints.
  • Pure Rewriting ($SHACL^b$): Because standard SHACL cannot easily propagate constraints across data edges (binary relations), the authors propose a slight extension called $SHACL^b$ to achieve a "pure" rewriting that executes directly over the original, unmodified data graph.
Fig. 3. Given the TBox  as in Example 3.4, the good successor configurations for the sets of 2-types 𝐹= {({𝐵0, 𝐵1}, {𝑟1}, {𝐴2}), ({𝐵0, 𝐵1}, {𝑟1}, {𝐴2})} and 𝐹′ = {({𝐵0, 𝐵1}, {𝑟1, 𝑟2}, {𝐴2})}, are succ(𝐹) = {({𝑟0, 𝑟1}, {𝐴0, 𝐴1}), ({𝑟2}, {𝐴2})} and succ(𝐹′) = {({𝑟0, 𝑟1}, {𝐴0, 𝐴1})}.

Datasets

Not discussed in the paper. This is a purely theoretical and foundational paper focused on computational complexity proofs and algorithmic correctness.

Key Insights and Ideas

  • Local Minimality Implies Global Core: The most significant theoretical breakthrough is showing that the local minimality enforced by their "austere" construction yields a global core model. This allows the algorithm to bypass the computationally expensive core-checking steps typical of traditional database chase variants.
  • Why the Standard Chase Fails: Traditional oblivious or Skolem chases introduce redundant anonymous nodes to satisfy existential qualifiers. While harmless for positive queries, these redundant nodes break SHACL validation when negation or universal quantification ($\forall$) is involved.
  • Data Tractability: Even though evaluating constraints across an ontology sounds computationally daunting, the authors show that the data complexity remains tightly bounded, meaning the approach scales well as the underlying dataset grows.

Key Results

  • Complexity Bounds: The authors map out the exact computational boundaries of the problem. SHACL validation in the presence of normalised $Horn-\mathcal{ALCHIQ}$ ontologies is ExpTime-complete in combined complexity (scaling with constraint/ontology size) but remains PTime-complete in data complexity (scaling with data size).
  • Hardness of Simplicity: Remarkably, they prove that even very simple ontology fragments (less expressive than OWL 2 QL) combined with a barebones version of SHACL (simple-SHACL) are enough to trigger ExpTime-hardness in combined complexity.

Limitations and Future Work

  • Syntactic Guards: To keep path equality and disjointness tractable during normalisation, the authors had to introduce an individual "guard" node. Dropping this guard without breaking the rewriting technique remains an open challenge.
  • Missing SHACL Features: The current fragment excludes counting quantifiers over regular path expressions and full, unstratified negation.
  • The Transitivity Obstacle: Extending this work to support transitivity axioms (moving from $Horn-\mathcal{ALCHIQ}$ to something like $Horn-\mathcal{SHIQ}$) is highly problematic because transitivity destroys the uniqueness of the core universal model, leaving the ideal choice for semantics unclear.

Summary updated

BibTeX
@misc{oudshoorn2025shacl,
  author = {Anouk Oudshoorn and Magdalena Ortiz and Mantas Simkus},
  title = {{SHACL Validation in the Presence of Ontologies: Semantics and Rewriting Techniques}},
  year = {2025},
  eprint = {2507.12286},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.12286},
}
Figure