<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Using Ontology Design Patterns To De ne SHACL Shapes</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Harshvardhan J. Pandit</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Declan O'Sullivan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Dave Lewis</string-name>
          <email>dave.lewisg@adaptcentre.ie</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ADAPT Centre, Trinity College Dublin</institution>
          ,
          <addr-line>Dublin</addr-line>
          ,
          <country country="IE">Ireland</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>SHACL shapes used for validation are not related to the axioms used in ontologies used to de ne the instances. One of the issues with using such axioms is their dependence on concepts which may not be used within the data graph, as well as the presence of other concepts and relationships which the axioms do not cover. By contrast, an Ontology Design Pattern (ODP) contains axioms that are closer to how its instances are de ned. In this position paper, we discuss the reuse of ODP axioms from modelling contexts to de ning SHACL shapes, using the use-case of MicroblogEntry ODP. The aim of this approach is to foster automated generation of SHACL shapes based on contexts, represented by an ODP, de ned within data graphs.</p>
      </abstract>
      <kwd-group>
        <kwd>Ontology Design Pattern</kwd>
        <kwd>RDF Validation</kwd>
        <kwd>SHACL</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>The Shapes Constraint Language (SHACL)1 is a language for describing and
validating RDF graphs, and is a W3C recommendation since July 2017. The set
of constraints used by SHACL for validation are expressed as an RDF graph
and are called `shapes' or `shape graphs' and the RDF data being validated is
called the `data graph'. Shapes o er a description of the data graph in the form
of constraints that a valid data graph satis es. This is based on the closed-world
assumption where all the required information is assumed to be present in the
correct format or is considered to be invalid. This allows shapes to be used for
other purposes such as code generation and data integration1.</p>
      <p>Creation of the validation conditions, called shapes in SHACL, is invariably
tied to the data within the graph, and is therefore dependant on the ontologies
used to model them. Such ontologies are modelled using axioms which serve
to provide constraints over the use of the ontology and can therefore also be
used to validate data. However, such axioms are only scoped to the ontology
they are de ned in, and therefore may not relate to other ontologies used within
the RDF graph. Additionally, the RDF graph may only use selective concepts
and properties from multiple ontologies. Such selective use may not be veri able
using axioms, which could depend on concepts and properties not used within</p>
      <sec id="sec-1-1">
        <title>1 https://www.w3.org/TR/shacl/</title>
        <p>the graph. Therefore, there is no reuse within the activities of modelling ontology
axioms, choosing ontologies for use in data graphs, and creating SHACL shapes
to validate the data graph.</p>
        <p>By contrast, an Ontology Design Pattern (ODP) captures only the concepts
and relationships necessary to de ne a particular context. Such ODPs can
combine concepts and relationships from multiple ontologies to express new
relationships between them. Since an ODP is smaller and more modular than a
comparatively larger ontology, the coverage of its terms used is larger in
instances based on it. Its axioms, therefore, are more suitable for validation, and
can be related to constraints in SHACL shapes.</p>
        <p>In this position paper, we discuss this similarity between the axioms used
to model ODPs and the constraints within SHACL shapes. We present our
argument in using ODP axioms for generating SHACL shapes for validation of
instances based on the pattern. Our aim is to investigate the automation of
SHACL shape generation from modular patterns for a given data graph. This
paper also serves to encourage the reuse of ODPs outside of modelling ontologies
for validating RDF graphs. The approach discussed in this paper is applicable
only to those graphs which use a selective set from multiple ontologies.</p>
        <p>The rest of the paper is structured as follows: Section 2 discusses the use of
ODP axioms to generate SHACL shapes, with an example provided in Section
3. Section 4 concludes this paper.
2</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>ODP axioms and SHACL shapes</title>
      <p>
        An axiom is de ned within description logic as a logical statement relating roles
and/or concepts [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Axioms in an ontology de ne constraints over concepts and
relationships that must be satis ed by the instances that use the ontology. These
axioms cannot be reused as part of an ODP as this can cause issues with missing
entities (dependencies) which are not part of the ODP. Instead, the ODP de nes
its own set of axioms that are limited to only those concepts and relationships
that are a part of it. In that sense, these axioms operate in a similar fashion to
the constraints within SHACL, which are based on the closed-world assumption.
      </p>
      <p>
        Existing work comparing OWL axioms and SHACL [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] nds the expressivity
of OWL being comparable to the SHACL Core vocabulary, and that syntactic
translation between OWL and SHACL is straight-forward in most cases.
Automating this process would involve two steps - the rst to identify the relevant
OWL statements forming a single constraint, and the second to then generate
their equivalent SHACL shape constraints. Since both OWL and SHACL are
essentially de ned using RDF triples, both steps can be performed
programmatically using the table of associated concepts mapping OWL and SHACL
constraints [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
The MicroBlog ODP [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] is based on real-world use-cases for modelling data
related to tweets (Twitter posts). It's core class, MicroblogEntry, de nes three
axioms describing constraints and relationships within the ODP, which are:
1. MicroblogEntry v 8 = 1hasPayload.Payload
2. MicroblogEntry v 8 = 1hasAuthor.Author
3. MicroblogEntry v 8 1writtenAt.Location
      </p>
      <p>These are de ned2 using rdfs:subClassOf and owl:Restriction as:
1 ### http://www.example.org/dase/MicroblogEntry#MicroblogEntry
2 :MicroblogEntry rdf:type owl:Class ;
3 rdfs:subClassOf :ReportingEvent ,
4 [ rdf:type owl:Restriction ;
5 owl:onProperty :hasPayload ;
6 owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
7 owl:onClass :Payload
8 ] ,
9 [ rdf:type owl:Restriction ;
10 owl:onProperty :hasAuthor ;
11 owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
12 owl:onClass :Author
13 ] ,
14 [ rdf:type owl:Restriction ;
15 owl:onProperty :writtenAt ;
16 owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
17 owl:onClass :Location
18 ] .</p>
      <p>These axioms can be used to directly generate the corresponding constraints
in a SHACL shape using sh:class and sh:quali ed(Max/Min)Count conditions.</p>
      <p>An example of this is the following SHACL shape:
1 :MicroblogEntryShape
2 a sh:NodeShape ;
3 sh:targetClass :MicroblogEntry ;
4
5 sh:property [
6 sh:path :hasPayload ;
7 sh:class :Payload ;
8 sh:MinCount 1;
9 sh:MaxCount 1;
10 ] ,
2 https://raw.githubusercontent.com/cogan-shimizu-wsu/MicroblogEntryOWL/
master/MicroblogEntry.owl</p>
      <p>While the SHACL shape de nes constraints for two axioms, the third axioms
de nes an optional triple, which does not provide a constraint on the data, and
hence is not part of the shape. It can be represented as a constraint with a
maximum of one to specify none or at most one location.
4</p>
    </sec>
    <sec id="sec-3">
      <title>Conclusion</title>
      <p>Through this position paper, we presented our arguments towards the use of
ontology design patterns (ODPs) to generate SHACL shapes. The approach uses
axioms de ned within ODPs to generate equivalent SHACL shape constraints
for data validation over a RDF dataset using those ODPs. The paper provides an
example of this, where the RDF triples representing the ODP axioms within an
OWL le are used to generate their corresponding SHACL shape. The paper also
discusses the possibility of automating the SHACL shape generation process.</p>
      <p>The paper emphasises the use of ODPs rather than ontologies as the basis
of validation. This is because RDF ontologies may contain multiple ontologies,
where the axioms in any ontology may not be su cient for veri cation of their
instances in the data graph. ODPs can capture such use-cases due to their smaller
and modular structure that allows representing axioms over multiple ontologies
in di erent ways to express varying contexts.</p>
      <p>This approach encourages the reuse of ODPs beyond the data modelling
phase. Relating such ODPs with their corresponding SHACL shapes provides
a way to visualise the model of the data as well as to validate it using the
same context. The ODPs de ned in this manner are modelled more closer to the
instances used in actual RDF graphs, and can therefore be used in approaches
such as data summarising, visualisation, and exploration. Conversely, ODPs can
assist approaches relevant to validation such as visualising SHACL shapes. This
can be done by taking SHACL shapes and generating corresponding ODPs to
represent their context.</p>
      <p>In terms of future work, the approach discussed in this position paper needs
to be validated in terms of mappings between (OWL) axioms and SHACL shape
constraints. In addition, the paper only considers the SHACL core vocabulary,
and needs an investigation of the features provided by SHACL advanced and
SHACL-SPARQL. The ability to convert OWL axioms to SPARQL queries
using approaches such as OWL2SPARQL3 would allow the generation of SHACL
shapes from ODPs by using the SHACL-SPARQL features. This could also
potentially assist in dealing with recursive constraints based on existing methods</p>
      <sec id="sec-3-1">
        <title>3 https://github.com/SmartDataAnalytics/OWL2SPARQL</title>
        <p>
          [
          <xref ref-type="bibr" rid="ref1 ref2">1,2</xref>
          ]. Based on these, an implementation of a proof-of-concept model needs to
be created to demonstrate the feasibility of the approach. Anti-patterns that
increase complexity for generation of SHACL shapes also need to be investigated.
        </p>
        <p>Our intended application is to automate the generation of SHACL shapes
from existing patterns/models describing the data. This will allow us to validate
a data graph based on speci c contexts (represented through ODPs), and reusing
the same validation mechanisms to check for existence and correctness of required
data in the graph. The reporting feature of SHACL would then be used to
produce a documentation based on the outcome of the validation to describe the
quality of data.</p>
        <p>Note: The paper,\Learning SHACL Constraints for Validation of Relation
Assertions in Knowledge Graphs" by Andre Melo and Heiko Paulheim, presents
work of relevance to this paper regarding generating SPARQL queries from
OWL axioms and using SHACL-SPARQL to use them as constraints. It was
submitted4 to ESWC 2018, but was not accepted.</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Acknowledgements</title>
      <p>This work is supported by the ADAPT Centre for Digital Content Technology
which is funded under the SFI Research Centres Programme (Grant 13/RC/2106)
and is co-funded under the European Regional Development Fund.
We also wish to thank Heiko Paulheim and Sebastian Rudolf for their discussion
and guidance in the comparison of axioms and SHACL constraints.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Corman</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reutter</surname>
            ,
            <given-names>J.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Savkovic</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          :
          <fpage>KRDB18</fpage>
          -
          <lpage>01</lpage>
          .pdf.
          <source>Technical Report KRDB18-01 (Apr</source>
          <year>2018</year>
          ), https://www.inf.unibz.it/krdb/KRDB%20files/ tech-reports/
          <fpage>KRDB18</fpage>
          -01.pdf
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Corman</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reutter</surname>
            ,
            <given-names>J.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Savkovic</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          :
          <article-title>Towards a Robust Semantics for SHACL: Preliminary Discussion</article-title>
          .
          <source>In: Proceedings of the 12th Alberto Mendelzon International Workshop on Foundations of Data Management. Cali</source>
          ,
          <string-name>
            <surname>Colombia</surname>
          </string-name>
          (
          <year>2018</year>
          ), http://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>2100</volume>
          /paper22.pdf
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Grau</surname>
            ,
            <given-names>B.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Horrocks</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Motik</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parsia</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Patel-Schneider</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sattler</surname>
            ,
            <given-names>U.</given-names>
          </string-name>
          :
          <article-title>OWL 2: The next step for OWL</article-title>
          .
          <source>Web Semantics: Science, Services and Agents on the World Wide Web</source>
          <volume>6</volume>
          (
          <issue>4</issue>
          ),
          <volume>309</volume>
          {322 (Nov
          <year>2008</year>
          ), http://www.sciencedirect.com/ science/article/pii/S1570826808000413
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Knublauch</surname>
          </string-name>
          , H.:
          <article-title>SHACL and OWL Compared (</article-title>
          <year>2017</year>
          -08-07), http://spinrdf.org/ shacl-and-owl.html
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Shimizu</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cheatham</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>An Ontology Design Pattern for Microblog Entries</article-title>
          .
          <source>In: Proceedings of the 8th Workshop on Ontology Design and Patterns (WOP</source>
          <year>2017</year>
          )
          <article-title>colocated with the 16th International Semantic Web Conference (ISWC</article-title>
          <year>2017</year>
          )
          <article-title>(</article-title>
          <year>2017</year>
          ), http://ceur-ws.
          <source>org/</source>
          Vol-2043/paper-06.pdf
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>