Semantics and Validation of Recursive SHACL

  • Julien Corman
  • Juan L. ReutterEmail author
  • Ognjen Savković
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11136)


With the popularity of RDF as an independent data model came the need for specifying constraints on RDF graphs, and for mechanisms to detect violations of such constraints. One of the most promising schema languages for RDF is SHACL, a recent W3C recommendation. Unfortunately, the specification of SHACL leaves open the problem of validation against recursive constraints. This omission is important because SHACL by design favors constraints that reference other ones, which in practice may easily yield reference cycles.

In this paper, we propose a concise formal semantics for the so-called “core constraint components” of SHACL. This semantics handles arbitrary recursion, while being compliant with the current standard. Graph validation is based on the existence of an assignment of SHACL “shapes” to nodes in the graph under validation, stating which shapes are verified or violated, while verifying the targets of the validation process. We show in particular that the design of SHACL forces us to consider cases in which these assignments are partial, or, in other words, where the truth value of a constraint at some nodes of a graph may be left unknown.

Dealing with recursion also comes at a price, as validating an RDF graph against SHACL constraints is NP-hard in the size of the graph, and this lower bound still holds for constraints with stratified negation. Therefore we also propose a tractable approximation to the validation problem.



This work was supported by the QUEST, ROBAST and OBATS projects at the Free University of Bozen-Bolzano, and the Millennium Institute for Foundational Research on Data (IMFD), Chile.


  1. 1.
    Akhtar, W., Cortés-Calabuig, Á., Paredaens, J.: Constraints in RDF. In: Schewe, K.-D., Thalheim, B. (eds.) SDKB 2010. LNCS, vol. 6834, pp. 23–39. Springer, Heidelberg (2011). Scholar
  2. 2.
    Arenas, M., Gutierrez, C., Pérez, J.: Foundations of RDF databases. In: Tessaris, S., et al. (eds.) Reasoning Web 2009. LNCS, vol. 5689, pp. 158–204. Springer, Heidelberg (2009). Scholar
  3. 3.
    Baader, F., Calvanese, D., McGuinness, D., Nardi, D., Patel-Schneider, P.: The Description Logic Handbook: Theory, Implementation and Applications. Cambridge University Press, Cambridge (2003)zbMATHGoogle Scholar
  4. 4.
    Berners-Lee, T., Hendler, J., Lassila, O.: The semantic web. Sci. Am. 284(5), 34–43 (2001)CrossRefGoogle Scholar
  5. 5.
    Boneva, I.: Comparative expressiveness of ShEx and SHACL (early working draft) (2016)Google Scholar
  6. 6.
    Boneva, I., Labra-Gayo, J.E., Hym, S., Prud’hommeau, E.G., Solbrig, H.R., Staworko, S.: Validating RDF with shape expressions. CoRR, abs/1404.1270 (2014)Google Scholar
  7. 7.
    Boneva, I., Labra Gayo, J.E., Prud’hommeaux, E.G.: Semantics and validation of shapes schemas for RDF. In: d’Amato, C., et al. (eds.) ISWC 2017. LNCS, vol. 10587, pp. 104–120. Springer, Cham (2017). Scholar
  8. 8.
    Corman, J., Reutter, J.L., Savkovic, O.: Semantics and validation of recursive SHACL (extended version). Technical report KRDB18-1. KRDB Research Center, Free Univ. Bozen-Bolzano (2018)Google Scholar
  9. 9.
    Corman, J., Reutter, J.L., Savkovic, O.: Validating graph data against recursive constraints: a semantics for SHACL. AMW (2018, to appear)Google Scholar
  10. 10.
    Dantsin, E., Eiter, T., Gottlob, G., Voronkov, A.: Complexity and expressive power of logic programming. ACM Comput. Surv. 33(3), 374–425 (2001)CrossRefGoogle Scholar
  11. 11.
    Donini, F.M., Nardi, D., Rosati, R.: Description logics of minimal knowledge and negation as failure. ACM Trans. Comput. Log. (TOCL) 3(2), 177–225 (2002)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Ekaputra, F.J., Lin, X.: SHACL4P: SHACL constraints validation within Protégé ontology editor. In: ICoDSE (2016)Google Scholar
  13. 13.
    Fischer, P.M., Lausen, G., Schätzle, A., Schmidt, M.: RDF constraint checking. In: Proceedings of the Workshops of the EDBT/ICDT 2015 Joint Conference, EDBT/ICDT, Brussels, Belgium, 27 March 2015, pp. 205–212 (2015)Google Scholar
  14. 14.
    Gelfond, M., Lifschitz, V.: The stable model semantics for logic programming, pp. 1070–1080. MIT Press (1988)Google Scholar
  15. 15.
    Harris, S., Seaborne, A., Prud’hommeaux, E.: SPARQL 1.1 query language. W3C Recomm. 21(10) (2013)Google Scholar
  16. 16.
    Kostylev, E.V., Reutter, J.L., Romero, M., Vrgoč, D.: SPARQL with property paths. In: Arenas, M., et al. (eds.) ISWC 2015. LNCS, vol. 9366, pp. 3–18. Springer, Cham (2015). Scholar
  17. 17.
    Motik, B., Horrocks, I., Sattler, U.: Bridging the gap between OWL and relational databases. Web Semant.: Sci. Serv. Agents World Wide Web 7(2), 74–89 (2009)CrossRefGoogle Scholar
  18. 18.
    Patel-Schneider, P.F.: Using description logics for RDF constraint checking and closed-world recognition. In: AAAI (2015)Google Scholar
  19. 19.
    Patel-Schneider, P.F., Franconi, E.: Ontology constraints in incomplete and complete data. In: Cudré-Mauroux, P., et al. (eds.) ISWC 2012. LNCS, vol. 7649, pp. 444–459. Springer, Heidelberg (2012). Scholar
  20. 20.
    Polleres, A., Wallner, J.P.: On the relation between SPARQL1.1 and answer set programming. J. Appl. Non-Class. Log. 23(1–2), 159–212 (2013)MathSciNetCrossRefGoogle Scholar
  21. 21.
    Staworko, S., Boneva, I., Labra-Gayo, J.E., Hym, S., Prud’hommeaux, E.G., Solbrig, H.: Complexity and expressiveness of ShEx for RDF. In: ICDT (2015)Google Scholar
  22. 22.
    Tao, J., Sirin, E., Bao, J., McGuinness, D.L.: Integrity constraints in OWL. In: AAAI (2010)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2018

Authors and Affiliations

  • Julien Corman
    • 1
  • Juan L. Reutter
    • 2
    Email author
  • Ognjen Savković
    • 1
  1. 1.Free University of Bozen-BolzanoBolzanoItaly
  2. 2.PUC Chile and IMFD ChileSantiagoChile

Personalised recommendations