---
title: SHACL-Based Update Language
url: https://www.emergentmind.com/topics/shacl-based-update-language
type: topic
---

# SHACL-Based Update Language

A SHACL-based update language is a formal system for specifying and reasoning over modifications to RDF graphs while ensuring compatibility with SHACL (SHApe Constraint Language) constraints. It enables precise characterization of class and property insertions/deletions through a structured, recursively defined syntax, and supports analysis of how updates affect SHACL validation in evolving knowledge graphs. The framework also provides techniques for static, data-independent validation of updates by means of translation (“regression”) into SHACL constraint satisfiability, accompanied by thorough complexity analysis and prototype tool support [2508.00137].

## 1. Formal Syntax for SHACL-Based Updates

The SHACL-based update language is grounded in disjoint infinite sets: nodes ($N_n$), class names ($N_c$), property names ($N_p$), shape names ($N_s$), and variables ($N_v$). Path expressions ($E$) and shape formulas ($\varphi$) are drawn from SHACL$^+$, extending ordinary SHACL with operations such as difference ($E \setminus F$) and “Cartesian” shape-property pairs $(\varphi_1,\varphi_2)$.

Basic update actions ($\beta$) are:
- $(B \oplus \varphi)$ inserts class $B$ for objects satisfying shape $\varphi$,
- $(B \ominus \varphi)$ removes class $B$,
- $(p \oplus E)$ inserts property $p$ for pairs in path $E$,
- $(p \ominus E)$ removes property $p$ according to path $E$,
with $B \in N_c$, $p \in N_p$, $\varphi$ and $E$ variable-free.

Complex actions ($\alpha$) are constructed as:
- $\alpha ::= \emptyset \mid \beta \cdot \alpha \mid (S?\,\alpha_1\,[\alpha_2])\cdot\alpha$,
where $S$ is a (possibly conditional) SHACL$^+$ shapes-graph formula; $S?\alpha_1$ is shorthand for $S?\alpha_1[\emptyset]$. The structure permits sequential composition and conditionals on graph validation.

## 2. Operational Semantics on RDF Graphs

Let $G$ be an RDF graph. The graph transformation induced by an action sequence $\alpha$ is defined recursively:
- $up(G,\emptyset) = G$
- $up(G,(B\oplus\varphi)) = G \cup \{B(a)\mid a\in\llbracket\varphi\rrbracket^G\}$
- $up(G,(B\ominus\varphi)) = G \setminus \{B(a)\mid a\in\llbracket\varphi\rrbracket^G\}$
- $up(G,(p\oplus E)) = G \cup \{p(a,b)\mid (a,b)\in\llbracket E\rrbracket^G\}$
- $up(G,(p\ominus E)) = G \setminus \{p(a,b)\mid (a,b)\in\llbracket E\rrbracket^G\}$
- $up(G,\beta\cdot\alpha) = up(up(G,\beta),\alpha)$
- $up(G,(S?\alpha_1[\alpha_2])\cdot\alpha) = \begin{cases}
    up(G,\alpha_1\cdot\alpha), & \text{if } G\models S \\
    up(G,\alpha_2\cdot\alpha), & \text{otherwise}
  \end{cases}$

$G\models S$ denotes SHACL$^+$ conformity, and $\llbracket-\rrbracket^G$ denotes shape evaluation.

## 3. Regression: Eliminating Updates via Constraint Rewriting

The regression technique rewrites shape graphs $S$ to simulate the effect of applying updates, reducing validation after updates to constraint satisfaction prior to the update. Given $tr_\alpha(S)$, the translation satisfies
$$
G\models tr_\alpha(S)\ \Longleftrightarrow\ up(G,\alpha)\models S.
$$
For $S=(C,T)$ (without Boolean connectives), translation is as follows:
- $tr_{\emptyset}(C,T) = (C,T)$
- $tr_{(B\oplus\varphi)\cdot\alpha}(C,T) = tr_\alpha(C,T)[B \leftarrow (B \vee \varphi)]$
- $tr_{(B\ominus\varphi)\cdot\alpha}(C,T) = tr_\alpha(C,T)[B \leftarrow (B \wedge \neg \varphi)]$
- $tr_{(p\oplus E)\cdot\alpha}(C,T) = tr_\alpha(C,T)[p \leftarrow (p \cup E)]$
- $tr_{(p\ominus E)\cdot\alpha}(C,T) = tr_\alpha(C,T)[p \leftarrow (p \setminus E)]$

For conditionals:
$$
tr_{(S'?\alpha_1[\alpha_2])\cdot\alpha}(C,T)
= (\neg S' \vee tr_{\alpha_1\cdot\alpha}(C,T)) \wedge (S' \vee tr_{\alpha_2\cdot\alpha}(C,T)).
$$
Inductive correctness is established (Theorem 3.2) [2508.00137].

## 4. Static Validation and Reduction to Satisfiability

The static validation problem asks whether a sequence $\alpha$ preserves $S$ on all $G$ satisfying $S$. Non-preservation is captured by the existence of $G$ and some grounding $\alpha^*$ such that $G\models S$ but $up(G,\alpha^*)\not\models S$. By regression, this is equivalent to $G\models S$ and $G\not\models tr_{\alpha^*}(S)$, i.e., the joint satisfiability of $S \wedge \neg tr_{\alpha^*}(S)$. It suffices to consider only groundings where variables in $\alpha$ are instantiated by constants appearing in $S\cup\alpha$ or a fresh constant (Theorem 4.2).

Summary:

| Problem                  | Reduction                              | Key Result/Condition     |
|--------------------------|----------------------------------------|--------------------------|
| Is $\alpha$ S-preserving?| $S\ \wedge\ \neg tr_{\alpha^*}(S)$ sat?| Finitely many groundings |

## 5. Complexity Classifications for Static Validation

- For unrestricted SHACL$^+$ (“SHACL$^\infty$”), static validation is undecidable, as is SHACL satisfiability.
- Restricting to the fragment SHACLᶠ (excluding path star ($E^*$), concatenation ($\cdot$), $E=p$, disj($E,p$), closed($P$)), where shapes are expressible in $\mathcal{ALCHOIQ}$ (a description logic), static validation is coNExpTime-complete.
- With further restrictions—only existential number restrictions ($n=1$), singleton shape-properties in paths—complexity drops to ExpTime-complete.

In both cases, the “co” reflects that non-preservation reduces to satisfiability of $S\wedge\neg tr(S)$ in a description logic whose finite satisfiability is in NExpTime or ExpTime (Theorem 4.3) [2508.00137].

## 6. Example: Discharging and Physician Handling in a Clinical RDF Graph

Given:

- Initial data graph $G$ with patients, patient status, physicians, and treatsPatient relations.
- Shapes graph $S = (C,T)$:
  - $C=\{$PatientShape $\leftrightarrow$ ActivePatient $\vee$ DischargedPatient, PhysicianShape $\leftrightarrow$ Physician $\vee$ $\exists$tr$P$.ActivePatient$\}$
  - $T=\{$(Patient,PatientShape), ($\exists$tr$P$,PhysicianShape)$\}$

Action $\alpha$:
- $(\mathrm{ActivePatient}\ominus p_2)\cdot(\mathrm{DischargedPatient}\oplus p_2)\cdot(\mathrm{Physician}\ominus\exists\mathrm{treatsPatient}.\{p_2\})$

Operationally:
1. Remove ActivePatient($p_2$); add DischargedPatient($p_2$); update physicians who only treat $p_2$.
2. $up(G,\alpha)\not\models S$ because Tom treats $p_2$ but is neither Physician nor treats active patient.
3. Compute $S' = tr_\alpha(S)$ via regression:
   - Replace ActivePatient by ActivePatient$\wedge\neg\{p_2\}$,
   - DischargedPatient by DischargedPatient$\vee\{p_2\}$,
   - Physician by Physician$\wedge\neg\exists$tr$P.\{p_2\}$,
   - $\exists$tr$P$.ActivePatient by $\exists$tr$P$(ActivePatient$\wedge\neg\{p_2\}$).
4. $G\not\models S'$, consistent with $up(G,\alpha)\not\models S$.
5. Modify update to safely remove Tom’s edge, and the new regression $S^*$ is satisfiable.

## 7. Implementation and Experimental Evaluation

The SHACL2FOL tool (Pareti et al.) was extended to:
- Parse SHACL$^+$ shapes-graphs and ground action lists,
- Emit TPTP files for FOL axiomatization of $S$ and $\neg tr_\alpha(S)$.

Vampire (finite-model mode) is used for satisfiability checking of $S \wedge \neg tr_\alpha(S)$. Empirical results on synthetic SHACL benchmarks:
- With 10 shapes and up to 200 actions, wall-clock time grows roughly linearly in the number of actions.
- With 20 actions and number of shapes scaled from 10 to 70, time grows exponentially (in accord with coNExpTime hardness).
- Vampire times out (fails to decide) on approximately 8–16% of cases, but typical examples up to 50 shapes and 100 actions are solved within seconds.

In sum, the SHACL-based update language provides a rigorous, modular framework for the controlled modification of RDF graphs under SHACL constraints, links update validation to SHACL constraint satisfiability through regression, characterizes the precise computational complexity of static validation for key language fragments, and offers practical implementation and evaluation—demonstrating both theoretical completeness and practical feasibility [2508.00137].

Source: https://www.emergentmind.com/topics/shacl-based-update-language