Source-linked AI summary

Rewrite Once, Validate Anywhere: Producing OWL-Aware SHACL Constraints (Extended Version)

Anouk Oudshoorn, Piotr Gorczyca, Dörthe Arndt

arXiv:2608.14104v1cs.LOcs.AI

TL;DR

SHACL validation often lacks full support for OWL’s implicit knowledge, requiring separate reasoning and validation steps. This paper rewrites SHACL shapes for OWL EL− ontologies, enabling direct validation, and reports success on all test cases where other approaches sometimes failed.

  • Problem

    SHACL implementations vary in their optional OWL reasoning support, complicating validation of RDF graphs that contain implicit ontological knowledge.

  • Method

    ShacOWL rewrites SHACL shapes using OWL EL− ontologies so standard SHACL validators can perform ontology-aware validation directly.

  • Results

    Only the rewriting approach was successful in all benchmark cases, while materialisation by reasoners often failed for more complex ontologies.

  • Takeaways & Limitations

    Rewritten shapes make validation results independent of a validator’s reasoning support and suitable for sharing across systems.

  • Takeaways & Limitations

    The evaluation is restricted to non-recursive SHACL and acyclic TBoxes, although the theory also covers recursive cases with least fixed point semantics.

Abstract

from arXiv · show

The Shapes Constraint Language (SHACL) is a W3C recommendation to express syntactic constraints, called shapes, on RDF graphs. SHACL validators are used to test whether a given graph adheres to such a shape. However, RDF graphs often come with OWL ontologies, whose implicit knowledge needs to be taken into account. This is classically handled by first applying reasoning and then performing the constraint checking on the results, often using different technologies which makes the process inefficient and vulnerable for mistakes. To overcome this, we propose to internalise the OWL axioms in the SHACL constraints; we construct a rewriting which takes as input both shapes and an OWL EL$^-$ ontology -- a fragment of OWL EL restricting the usage of existential restrictions -- and produces SHACL constraints. This output can then be evaluated by any validator supporting SHACL core regardless of its reasoning support, while yielding the same results as the traditional approach. The implementation of our translation is evaluated both against applying state-of-the-art reasoners and validators consecutively, as against validators with built-in reasoning support. For our benchmark, we show that our approach is in general more efficient in finding violations compared to the sequential approach, thus providing a powerful tool which simplifies combining reasoning with validation.

2 Computational Logic Group, TU Dresden, Germany

This section highlights the paper’s focus on SHACL validation, OWL reasoning, and rewriting.

  • SHACL validation is a central topic of the section.
  • OWL reasoning is identified as a central topic.
  • Rewriting is identified as a central topic.

1 Introduction

The introduction identifies the technical overhead of executing OWL reasoning and SHACL validation in separate systems and motivates ontology-aware SHACL rewriting. It presents ShacOWL, which extends prior theory while restricting right-hand existential usage to avoid exponential blow-ups.

  • Motivation: SHACL implementations generally provide limited reasoning support, so complex OWL reasoning and validation are often handled by two independent systems.This separation creates technical overhead, while OWL reasoners may be poorly maintained and may materialise facts irrelevant to validation.
  • Rewriting approach: Ontology-aware rewriting can encode ontology consequences directly in SHACL targets and constraints, allowing constraint checking alone to find violations otherwise detected after reasoning.Examples include targeting Student instances through a Person shape and replacing a name path with an alternative path covering studentName.
  • Relation to prior rewriting: The proposed SHACL rewriting differs from classical OWL-QL SPARQL rewriting because SHACL graphs contain multiple potentially dependent shapes rather than one existing query.The introduction notes that classical rewriting does not allow recursion beyond SPARQL property paths, whereas shape dependencies motivate a different treatment.
  • Scope and prior work: The paper excludes the OWL RL fragment because planned SHACL rule support could express RL rules directly or allow engines to handle them through corresponding rules.The introduction also notes existing ontology-based SHACL rewritings for OWL QL and related description logics, including approaches with exponential worst-case complexity.
  • Contribution: ShacOWL rewrites SHACL shapes using OWL ontologies to enable ontology-aware validation and extends existing theory with nominals, role chains, and qualified existential restrictions on ontology-axiom left-hand sides.The approach limits existential restrictions on the right-hand side because they are identified as the main cause of exponential blow-ups.

2 Preliminaries

This section establishes the formal preliminaries for data graphs, interpretations, and non-recursive SHACL constraints. It also defines constraint sets, targets, shapes graphs, and their validation semantics.

  • Data Graphs: Data graphs use disjoint sets of concept names, role names, and individuals, with atoms formed as class assertions A(c) or role assertions p(c,c′).Roles include inverses, with (p−)− = p.
  • Interpretations: An interpretation assigns concepts to domain subsets, roles to binary relations, and individuals to domain elements; the canonical interpretation is induced directly by a data graph.The canonical domain contains all individuals occurring in the graph.
  • (Non-recursive) SHACL: Non-recursive SHACL constraints combine constants, shape names, concepts, negation, conjunction, qualified cardinalities, and equality or disequality of regular path expressions.Regular path expressions are built over roles using union, concatenation, and Kleene star.
  • Validation: A constraint set contains at most one definition per shape name and has no cyclic dependencies, while validation is defined recursively through shape-expression semantics.The semantics is given by the function I(·) in Figure 1.
  • Validation: A shapes graph comprises a constraint set and targets, and an interpretation validates it when every targeted node validates its assigned shape.Targets may select individual nodes or all nodes in a designated set; data-graph validation uses the canonical interpretation.

3 Ontology Language OWL EL−

OWL EL− is introduced as a tractable OWL EL fragment corresponding to EL++, but forbidding existential restrictions on axiom right-hand sides. The rewriting assumes syntactic restrictions and primarily uses acyclic TBoxes with non-recursive SHACL, although cyclic cases remain theoretically correct with recursive semantics.

  • Language definition: OWL EL− corresponds to EL++ while disallowing existential restrictions on the right-hand side of axioms.Riskman is given as an example ontology expressible in this fragment.
  • Language definition: OWL EL− TBoxes contain role inclusions, restricted role compositions, and concept inclusions built from ⊤, names, nominals, ranges, conjunctions, and existential restrictions.The language also uses dom(p) as shorthand for ∃p.⊤, and expressions allowed on axiom left-hand sides are OWL EL− concepts.
  • Syntactic restrictions: To preserve tractability, composition axioms p′ ◦p ⊑p′′ are reduced to p ◦p ⊑p, which still expresses transitivity.This is slightly weaker than Baader et al.’s syntactic restriction.
  • Syntactic restrictions: Counting to at least two over complex path expressions is restricted to simple roles, excluding relevant role-composition or role-inclusion axioms when ≥n p.φ occurs.The restriction applies jointly to concepts C and TBoxes T.
  • Rewriting assumptions and limitations: The rewriting considers acyclic TBoxes and uses non-recursive SHACL, although cyclic TBoxes remain theoretically correct through stratified recursive constraints under least fixed point semantics.The authors limit evaluation because principled recursion support is scarcely implemented, citing shaWell as a proof-of-concept.

4 Combining SHACL and OWL

This section defines OWL-aware SHACL validation through the least canonical model induced by an OWL EL− TBox and data graph. It then establishes a one-time shapes-graph rewriting that makes direct SHACL validation equivalent to validation after OWL reasoning.

  • Semantics: The canonical interpretation of A_T is a minimal model of the OWL EL− TBox T and data graph A.For every model J of (T, A), the canonical interpretation is contained in J on all concept and role interpretations.
  • Semantics: Validation under OWL EL− semantics is defined by testing whether the canonical closure A_T validates the original shapes graph.Formally, (T, A) validates (C, G) whenever A_T validates (C, G).
  • Rewriting: For every shapes graph (C, G) and OWL EL− TBox T, a rewritten graph (C_T, G_T) validates on A exactly when (C, G) validates on A_T.This theorem establishes equivalence between direct validation and the traditional reasoning-then-validation approach.
  • Rewriting: The rewritten shapes graph is computed once and can then be reused for every data graph and every update of those graphs.This avoids recomputing the OWL-aware shapes transformation during validation.
  • Rewriting: The rewriting has two phases: constraint rewriting integrates T into constraints, while target rewriting addresses nodes targeted through implications of T.The example illustrates both phases by deriving B(a) and q(a, b), adding implied targets, and replacing ∃q.⊤ with ∃(p ∪q).⊤.

5 Rewriting Techniques

The rewriting internalizes OWL EL^- reasoning in SHACL by translating concepts, roles, targets, and constraints into SHACL shapes. It is correct, data-independent, and introduces only linear growth in the TBox size apart from role-expression expansion.

  • Concept and constraint rewriting: Concept translations define shapes whose memberships coincide with OWL derivability for every relevant concept and individual.For X ∈ sub(T), c ∈ IA(sC) iff c ∈ C^IAT.
  • Target rewriting: Bridge-shapes update shape targets by constraining universally targeted nodes that satisfy the corresponding OWL concept.Universal targeting is implemented using class, property, and individual declarations together with an implication encoded as a disjunction.
  • Role rewriting: Role inclusions and role chains are compiled through dependency relations and regular-path substitutions, with transitive roles treated specially to permit repeated steps.For example, p3 expands to (p0 ∪ p1)∗·(p2 ∪ p3), while a transitive p3 would additionally include p3 in the prefix closure.
  • Concept and constraint rewriting: Constraint rewriting replaces each concept name B with sB, a shape collecting exactly the nodes for which B is derivable in T.This substitution transfers the ontology-aware concept classification into the rewritten SHACL constraint set.
  • Correctness and size: The rewriting is correct because translated concept and role semantics combine with bridge-shapes to preserve validation results for all nodes.For nodes satisfying the bridge condition, validation is equivalent to the original shape; other nodes satisfy the bridge-shape independently.
  • Correctness and size: The rewriting is data independent, introduces linearly many shapes in the TBox size, and can grow further only through role expressions determined by role hierarchies.Its size remains constant with respect to the data graph, while rewritten-constraint blow-up depends on the role-hierarchy structure.

6 Implementation and Evaluation

ShacOWL7 rewrites OWL EL− ontologies and SHACL shapes so standard SHACL validators can reproduce reasoning-aware validation without a separate reasoner. Experiments on 1,500 benchmarks show substantially lower rewriting time than reasoner-based materialisation, while deep rewritten shape nesting exposes validator limitations.

  • Implementation: ShacOWL7 uses rdflib.js v2.2.37 to rewrite OWL EL− TBoxes and SHACL shapes, encoding terminological knowledge directly into constraints.The rewritten shapes are intended to provide the same validation results without requiring a separate reasoner.
  • Benchmarks and Experiments Setup: The comparison covered 12 reasoner-plus-validator baseline combinations, four ShacOWL rewriting combinations, and two pySHACL inference configurations.The baseline materialised data with Pellet, HermiT, or JFact before validation; pySHACL used OWL RL or OWL RL+RDFS inference.
  • Benchmarks and Experiments Setup: The evaluation used 1,500 acyclic benchmarks across 15 difficulty levels, varying ontology size, logical constructs, and shape complexity.Each benchmark contained an OWL EL− TBox, SHACL shapes, and a data graph, with 100 benchmarks per level.
  • Results Analysis: Rewriting took a little over one hour across all test cases, whereas Pellet required almost 44 hours for materialisation.The comparison concerns total rewriting time versus the fastest reported reasoner’s total materialisation time.
  • Results Analysis: pySHACL reported significantly more validation errors because the tested version supported shapes only to depth 30, unlike the deeply nested shapes produced by rewriting.A single original shape can become a chain of four dependent shapes after rewriting.

7 Discussion: towards OWL EL

Extending the rewriting method from OWL EL− to full OWL EL raises challenges involving existentially introduced edges, especially edges to existing nominals and edges with unspecified objects. Proposed simulations depend on ontology-triggered conditions, while current SHACL targeting lacks the needed cross-shape Boolean combinations and unrestricted existential handling can be exponentially complex.

  • Towards full OWL EL: Full OWL EL introduces two main challenges: edges to existing nominals and edges whose objects are unspecified in axioms.The discussion addresses these challenges in that order.
  • Existential restrictions to nominals: Existential restrictions to nominals require simulating jumps from nodes in C to nominal c whenever p occurs in a shape expression.For example, C ⊑∃p.c can affect a constraint s ←≥2 p.φ targeting s(a).
  • Existential restrictions to nominals: Because validators generally lack a universal role, the rewrite must encode the ontology axiom’s triple structure to simulate these non-random jumps.The proposed structure includes type(a, C), subclassOf(C, x), someValuesFrom(x, y), oneOf(y, z), and first(z, c).
  • Existential restrictions to nominals: A natural alternative uses Boolean combinations of targets to validate node c while conditioning on the required facts at node a.The example is s(a)∨(s′(a)∧s′′(c)), with s ←≥2 p.φ as the original constraint.
  • Existential restrictions to nominals: SHACL 1.2 shape targets can target nodes conforming to a shape, but do not support Boolean combinations of targets across different shapes.Therefore, it remains unclear whether the targeting approach needed here will be supported soon.
  • Existential restrictions: ExpTime-complete combined complexity is already known for rewriting SHACL with unrestricted existential restrictions in relatively inexpressive OWL QL fragments.The cited works study fragments without nominals; the exponential blow-up stems from considering every possible data configuration.

8 Conclusion and Outlook

The work advances ontology-aware shapes rewriting toward practical application by targeting OWL EL−, detailing the rewriting process, and providing a reusable implementation. It also evaluates the approach against alternatives.

  • Practical contribution: The study presents an initial step from theoretical ontology-aware shapes rewriting toward practical application.The authors characterize the work as a first step toward applying ontology-aware rewriting in practice.
  • OWL EL− fragment: OWL EL− is identified as expressive enough for non-trivial use cases while remaining relatively easy to incorporate into SHACL shapes.The fragment is selected as a balance between expressivity and implementation effort.
  • Implementation: The paper details the rewriting procedure and provides an implementation intended for reuse in other work.The implementation operationalizes the proposed rewriting approach.
  • Evaluation: The authors conduct an evaluation and compare the rewriting approach with alternative methods.The supplied conclusion passage states that an evaluation and comparison were performed, but does not specify the compared methods in full.

Appendix

The appendix documents the Turtle encoding of the rewriting example, the benchmark-generation procedures, and supplementary evaluation statistics. It also describes how benchmark instances and timing results are organized across difficulty levels and approaches.

  • Benchmarks Generation: The benchmark generator uses three algorithms to create OWL EL− TBoxes, data graphs, and SHACL shapes with randomly generated property paths.GenerateTBox creates ontology symbols and individuals; GenerateDataGraph adds class and role assertions; GenerateSHACL creates shapes and targets.
  • Benchmarks Statistics: The evaluation contains 1,500 randomly generated instances across 15 difficulty levels, with most instances non-conforming and level 1 evenly split between positive and negative cases.From level 2 onward, virtually all instances are negative; Table 3 also reports mean RDF triple counts for the generated inputs and rewriting outputs.
  • Extra Results: Supplementary tables report timing ranges and shared-instance results, excluding approaches that fail to solve too many instances where specified.Table 4 uses successfully completed instances, while Tables 5 and 6 restrict evaluation to instances solved by every included approach.
Loading 2608.14104v1…