=Paper=
{{Paper
|id=Vol-3747/dqmlkg_paper4
|storemode=property
|title=Extending Shape Expressions for different types of knowledge graphs
|pdfUrl=https://ceur-ws.org/Vol-3747/dqmlkg_paper4.pdf
|volume=Vol-3747
|authors=Jose Emilio Labra Gayo
|dblpUrl=https://dblp.org/rec/conf/text2kg/Emilio24
}}
==Extending Shape Expressions for different types of knowledge graphs==
Extending Shape Expressions for different types of
knowledge graphs
Jose Emilio Labra-Gayo1
1
WESO lab - University of Oviedo
Abstract
Shape Expressions (ShEx) has been proposed as a concise and human-readable language to describe
and validate RDF. Inspired by regular expressions, it offers an expressive formalism to describe graph
structures based on regular bag expressions. Although plain RDF is one of the common data formats
employed to represent knowledge graphs, there have been several proposals to either extend RDF with
the so-called RDF-Star or RDF 1.2, or to employ other formalisms like property graphs. In this paper
we present an overview and comparison of those approaches and propose three possible extensions of
ShEx: ShEx-Star which can be used to validate RDF-Star, ShEx-N: that can be used when nodes also
act as properties in RDF and PShEx, which can be used to describe property graphs. We present some
examples and a semantics of each extension.
1. Introduction
Although Knowledge graphs have been successfully adopted by the industry, an important
aspect of their practical application is the quality of the data that they contain. In order to
increase their quality, it is necessary to have some mechanisms that can check the conformance
of the data to some kind of schema. Knowledge graphs are usually considered schema-less,
because there is no mandatory schema, however, in most cases the data curators have an implicit
schema in mind. Having the possibility to materialize that implicit schema into a machine
processable form that can be automatically verified can mitigate the risk of non-conformant
data.
In practice, there are several types of technologies that can be used for knowledge graphs [1]:
Directed edge-labeled graphs, whose main representative are RDF graphs, and Property graphs,
which allow propertyβvalue pairs and labels to be associated with nodes and edges.
In the case of RDF, two main technologies have been proposed for validation: ShEx [2] and
SHACL [3], which are based on the notion of a shape as a description of the topology of some
specific kind of nodes. In this way, it is possible to define a schema as a set of shapes which
describe the expected properties of some nodes, their expected cardinalities and the kind of
nodes. These schemas, can be used to validate RDF data and check if it conforms to those shapes.
We employ ShEx in the paper because it can be seen as a description language for RDF acting
as grammar where a ShEx schema represents the set of all the RDF graphs that conform to it.
Envelope-Open labra@uniovi.es (J. E. Labra-Gayo)
GLOBE http://labra.weso.es (J. E. Labra-Gayo)
Orcid 0000-0001-8907-5348 (J. E. Labra-Gayo)
Β© 2022 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
CEUR
Workshop
Proceedings
http://ceur-ws.org
ISSN 1613-0073
CEUR Workshop Proceedings (CEUR-WS.org)
CEUR
ceur-ws.org
Workshop ISSN 1613-0073
Proceedings
There has been a proposal for an extension of RDF called RDF-Star [4] and a Working Group
is currently working taking that proposal as input to define what is currently called RDF
1.2 [5]. The proposal extends RDF with the possibility of having triples as subjects or objects
in statements. The relationship between that extension and property graphs has already been
studied [6].
Although ShEx was defined to describe and validate RDF, we consider that it can be extended
to describe and validate RDF-Star (or RDF 1.2), so in this paper we explore a possible extension
of the language in that direction. Apart from that, the shapes in ShEx are usually centered
on describing nodes that act as either subjects or objects, but in RDF, it is also possible to
add statements whose subjects or objects are also the predicates of other statements. We also
explore a possible extension of ShEx where it is possible to define shapes about nodes that act as
properties. Finally, although there have been several proposals to define schemas for property
graphs, we consider that the grammar-based approach of ShEx can also be helpful, so we also
explore what it would look like to extend ShEx for describing and validating property graphs.
The main contributions of this paper are to present three extensions of ShEx: ShEx-Star
for RDF-Star (section 3), ShEx-N for describing nodes as properties (section 4) and PShEx for
property graphs (section 5), with their abstract syntax and semantic definitions.
2. RDF and ShEx
Definition 1 (RDF triple and RDF Graph). Given a set of IRIs I , a set of blank nodes B and a set
of literals Lit, an RDF triple is a tuple (π , π, π) where π β I βͺ B is called the subject, π β I is called
the predicate and π β I βͺ B βͺ Lit is called the object. An RDF graph G is a set of RDF triples.
There are several syntaxes for RDF graphs like Turtle, N3, RDF/XML, etc. In this document,
we will use Turtle.
Example 1 (Example of an RDF graph in Turtle). The following snippet contains a simple RDF
graph with two nodes :a and :b .
prefix :
:a :name "Alice" ;
:knows :b .
:b :firstname "Robert", "Julius" ;
:lastname "Smith" .
The neighbors of a node π β V in an RDF graph G are defined as ππππβπ (π, G) = {(π, π, π¦) β£
(π, π, π¦) β G} βͺ {(π₯, π, π) β£ (π₯, π, π) β G} βͺ {(π₯, π, π¦) β£ (π₯, π, π¦) β G}.
Shape Expressions (ShEx) were proposed as such a language in 2014 [2]. It was designed as a
high-level and concise domain-specific language to describe RDF. The syntax of ShEx is inspired
by Turtle and SPARQL, while the semantics was inspired by RelaxNG and XML Schema. In this
section we describe a simplified abstract syntax of ShEx following [7]1 .
1
The full specification of ShEx is available at https://shex.io/shex-semantics/
:knows
:a :b
:name :rstname :rstname :lastname
"Alice" βRobert" βJulius" βSmith"
Figure 1: Basic RDF graph example
Definition 2 (ShEx schema). A ShEx Schema is defined as a tuple β¨L, πΏβ© where L is the set of
shape labels, and πΏ βΆ L β S is a total function from labels to shape expressions. The set of
shape expressions π π β S is defined using the following abstract syntax:
π π ::= cond Basic boolean condition on nodes (node constraint)
| π π1 AND π π2 Conjunction of π π1 and π π2
| @l Shape label reference for l β L
| CLOSED {π‘π} Closed shape
| {π‘π} Open shape
π‘π ::= π‘π1 ; π‘π2 Each of π‘π1 and π‘π2
| π‘π1 β£ π‘π2 Either π‘π1 or π‘π2
| π‘πβ Zero or more π‘π
π
| β
β π π Outgoing Triple with predicate π and object conforming to π π
π
| π π β
β Incoming triple with predicate π and subject conforming to π π
| π Empty triple expression
Intuitively, shape expressions define conditions about nodes while triple expressions define
conditions about the neighborhood of nodes, and shapes qualify those neighborhoods by
allowing (open shapes) or disallowing (closed shapes) triples with other predicates. We omit
negation and disjunction operator to simplify the interactions between negation and recursion,
which led to a stratified negation requirement in ShEx.
The restrictions imposed on shape expressions schemas in [8] also apply here. Namely, in a
schema (L, πΏ, S)
β’ The shape label references used by the definition function πΏ are themselves defined, i.e. if
@l appears in some shape definition, then l belongs to L;
β’ No definition πΏ(l) uses a reference @l to itself, neither directly nor transitively, except
π
while traversing a shape. For instance, πΏ(l) = @l AND π π is forbidden, but πΏ(l) = { β
β @l}
is allowed.
Example 2 (Example of ShEx schema). A ShEx schema that describes the RDF graph presented
in example 1 can be defined as:
L = {ππππ ππ }
ππππ π ππ π‘ππππ πππ π‘ππππ
πΏ(ππππ ππ) = { ( βββββ ππ‘ππππ β£ ββββββββ ππ‘ππππ*; βββββββ ππ‘ππππ);
ππππ€π
ββββββ @ππππ ππ *
}
ShEx has several concrete syntaxes like a compact syntax (ShExC) and an RDF syntax defined
based on JSON-LD (ShExJ) 2 .
Example 3. An example of a ShEx schema using ShExC compact syntax.
prefix :
prefix xsd:
{
(:name xsd:string |
:firstname xsd:string * ; :lastname xsd:string );
:knows @ *
}
The semantics of ShEx schemas is based on a conformance relation parameterized by a
shape assignment: we say that node π in graph G conforms to shape expression π π with shape
assignment π, and we write G, π, π β¨ π π.
The following rules are defined similar to [9], where it is shown that there exists a unique
maximal shape assignment πmax that allows us to define conformance independently of the
shape assignment. The conformance relation is defined recursively on the structure of π π by the
set of inference rules presented in table 1 where πππππ (π‘π) is the set of predicates that appear in
a triple expression π‘π and can be defined as:
ππππ(π) = π‘ππ’π G, π, π β¨ π π1 G, π, π β¨ π π2
πΆπππ π΄π π·
G, π, π β¨ ππππ G, π, π β¨ π π1 AND π π2
πΏ(l) = π π G, π, π β¨ π π ππππβπ (π, G) = π‘π G, π‘π , π β© π‘π
πβππππ
ππ πΆπππ πππβπππ
G, π, π β¨ @π G, π, π β¨ CLOSED {π‘π}
π‘π = {β¨π₯, π, π¦β© β ππππβπ (π, G) β£ π β πππππ (π‘π)} G, π‘π , π β© π‘π
πππππβπππ
G, π, π β¨ {π‘π}
Table 1
Inference rules for ShEx shape expressions
πππππ (π‘π1 ; π‘π2 ) = πππππ (π‘π1 ) βͺ πππππ (π‘π2 )
πππππ (π‘π1 β£ π‘π2 ) = πππππ (π‘π1 ) βͺ πππππ (π‘π2 )
π
πππππ ( β β π‘π) = {π}
πππππ (π‘πβ) = πππππ (π‘π)
πππππ (π) = β
The rules for node constraints (πΆπππ) and conjunction are as expected. A node π conforms
to an open shape with triple expression π‘π if its neighborhood restricted to the triples with
predicates from π‘π conform, meaning that triples whose predicates are not mentioned in π‘π are
2
See ShEx specification [8] for details.
not constrained by the shape (rule πππππβπππ). Conformance to a closed shape requires to
consider the whole neighborhood of the node (rule πΆπππ πππβπππ).
Conformance to a triple expression uses a second relation defined on sets on neighborhood
triples π‘π instead of nodes π. The set of neighborhood nodes π‘π of a graph G conforms to a triple
expression π‘π with shape assignment π, written as G, π‘π , π β© π‘π, as defined by the inference rules
in table 2.
(π‘π 1 , π‘π 2 ) β ππππ‘(π‘π ) G, π‘π 1 , π β© π‘π1 G, π‘π 2 , π β© π‘π2
πΈππβππ
G, π‘π , π β© π‘π1 ; π‘π2
G, π‘π , π β© π‘π1 G, π‘π , π β© π‘π2
πππππ1 πππππ2
G, π‘π , π β© π‘π1 β£ π‘π2 G, π‘π , π β© π‘π1 β£ π‘π2
π‘π = {β¨π₯, π, π¦β©} G, π¦, π β¨ π π π‘π = {β¨π¦, π, π₯β©} G, π¦, π β¨ π π
π πΆ1 π πΆ2
π π
G, π‘π , π β© β
β π π G, π‘π , π β© π π β
β
(π‘π 1 , π‘π 2 ) β ππππ‘(π‘π ) G, π‘π 1 , π β© π‘π G, π‘π 2 , π β© π‘πβ
ππ‘ππ2 ππ‘ππ1
G, π‘π , π β© π‘πβ G, β
, π β© π‘πβ
Table 2
Inference rules for ShEx triple expressions
A shape assignment π for graph G and S is called valid if for every node π in G and every
shape expression label l defined in S, if π@l β π, then G, π, π β¨ @l.
According to Boneva et al [7], for every graph G, there exists a unique maximal valid shape
assignment πmax such that if π is a valid shape assignment for G and S, then π β πmax .
3. RDF-Star and ShEx-Star
RDF-Star has been proposed as an extension of RDF where the subjects and objects can be
triples. We present a formal definition of RDF-Star based on [10]:
Definition 3 (RDF-Star). An RDF-Star triple is a tuple π‘ defined recursively as follows: Any
RDF triple π‘ β (I βͺ B) Γ I Γ (I βͺ B βͺ Lit) is an RDF-Star triple; and given RDF-Star triples π‘ and π‘ β²
and RDF terms π β (I βͺ B), π β I and π β (I βͺ B βͺ Lit), the tuples (βͺ π‘ β«, π, π), (π , π, βͺ π‘ β² β«) and
(βͺ π‘ β«, π, βͺ π‘ β² β«) are RDF-Star triples. An RDF-Star graph is a set of RDF-Star triples.
Example 4 (Example of an RDF-Star graph in Turtle-Star notation). The following snippet
contains a simple RDF-Star graph with two nodes :a and :b .
prefix :
:a :name "Alice" .
<< :a :knows :b >> :certainty 0.5 .
:b :firstname "Robert", "Julius" ;
:lastname "Smith" .
:knows :certainty
:a :b "0.5"
:name :ο¬rstname :ο¬rstname :lastname
"Alice" βRobert" βJulius" βSmith"
Figure 2: Basic RDF-Star example
We can extend ShEx to support ShEx-Star by adding the following declaration to the definition
of triple expressions π‘π:
π‘π ::= . . . Same definitions as in 2
π
| βͺ β
β π π β«{|π‘π|} Outgoing Triple term constraint with predicate π
π
| βͺ π π β
β β«{|π‘π|} Incoming triple term constraint with predicate π
Example 5 (Example of a ShEx-Star schema). A ShEx-Star schema that describes the RDF
graph presented in example 4 can be defined as:
ππππ π ππ π‘ππππ πππ π‘ππππ
πΏ(ππππ ππ) = { ( βββββ ππ‘ππππ β£ ββββββββ ππ‘ππππ*; βββββββ ππ‘ππππ);
ππππ€π ππππ‘ππππ‘π¦
βͺ ββββββ @ππππ ππ β«{| βββββββ π·ππππππ|}*
}
π
The expression βͺ β β π π β«{|π‘π|} describes a triple term whose predicate is π and whose
object conforms to the shape expression π π and that can be the subject of triples conforming to
triple expression π‘π. The formal semantics can be described as:
π‘π = {β¨βͺ π‘ β«, π, π¦β©} G, π¦, π β¨ π π ππππβπ (βͺ π‘ β«, G) = π‘π β² G, π‘π β² , π β© π‘π
π π πΆ1
π
G, π‘π , π β©βͺ β
β π π β« {|π‘π|}
π‘π = {β¨π₯, π, βͺ π‘ β«β©} G, π₯, π β¨ π π ππππβπ (βͺ π‘ β«, G) = π‘π β² G, π‘π β² , π β© π‘π
π π πΆ2
π
G, π‘π , π β©βͺ π π β
β β« {|π‘π|}
Table 3
Inference rules for ShEx-Star new triple term expressions
4. ShEx-N: Describing nodes that act as properties
In the RDF data model, predicates can also act as subjects or objects or triples. This aspect is
not taken into account in traditional ShEx, where the shapes describe the topology of nodes
without considering their potential role as predicates.
Example 6 (Example of an RDF graph a node acting as a property). The following snippet
contains a simple RDF graph where :knows is both a node and a property.
prefix :
prefix skos:
:a :name "Alice" ;
:knows :b .
:b :firstname "Robert", "Julius" ;
:lastname "Smith" .
:knows skos:related :Friendship .
:Friendship
skos:related
:knows
:a :b
:name :ο¬rstname :ο¬rstname :lastname
"Alice" βRobert" βJulius" βSmith"
Figure 3: RDF example with a property as a node
In order to capture these appearances in a single shape, it is possible to add a new kind of
triple expression:
π‘π ::= . . . Same definitions as in 2
| π π1 ββ π π2 Triple constraint with focus node acting as predicate and subject
conforming to π π1 and object conforming to π π2
The semantics of triple term constraints can be defined as:
π‘π = {β¨π , π₯, πβ©} G, π , π β¨ π π1 G, π, π β¨ π π2
π π1
G, π‘π , π β© π π1 β
β π π2
Table 4
Inference rules for ShEx-N
Example 7 (Example of a ShEx-N schema). The following ShEx-N schema defines the shape
πΉ πππππ βπππππππππ‘π¦ which validates the node :knows in example 6:
π πππ βΆπππππ‘ππ
πΏ(πΉ ππππππβπππππππππ‘π¦) = { ββββββββββ [βΆ πΉ ππππππ βππ] ;
@ππππ ππ ββ @ππππ ππ
}
βΆππππ
πΏ(ππππ ππ) = { ββββββ ππ‘ππππ
βΆπ πππ π‘ππππ βΆπππ π‘ππππ
β£ βββββββββ ππ‘ππππ* ; ββββββββ ππ‘ππππ ;
ππππ€π
ββββββ @ππππ ππ *
}
5. Property graphs and PShEx
Property graphs have become popular thanks to several commercial graph databases like Neo4j 3 ,
JanusGraph 4 or Sparksee 5 . A property graph has unique identifiers for each node/edge and
allows to add property-value annotations to each node/edge in the arc as well as type annotations.
The following definition of a property graph follows [11].
Definition 4 (Property graph). Given a set of types T , a set of properties P, and a set of values
V , a property graph G is a tuple β¨N , E, π, ππ , ππ , π β© where N β© E = β
, π βΆ E β¦ N Γ N is a total
function, ππ βΆ N β¦ πΉ πππππ‘(T ), ππ βΆ E β¦ T , and π βΆ N βͺ E Γ P β¦ πΉ πππππ‘(V ).
A property graph is formed by a set of node identifiers N and a set of edges E where π
associates a pair of nodes (π1 , π2 ) to every π β E where π1 is the subject and π2 is the object, ππ
associates a set of types for node identifiers (notice that property graphs allow nodes to have
more than one type), ππ associates a types for each edge identifier, and π associates a set of
values to pairs (π, π) such that π β N βͺ E is a node or edge and π β P is a property.
Example 8. As an example, we will represent information that Alice knows Robert with a
certainty of 0.5
T = {Person, knows} P = {name, certainty} V = {βAliceβ, βRobertβ, βJuliusβ, βSmithβ, 0.5}
N = {π1 , π2 } E = {π1 } π = π1 β¦ (π1 , π2 )
ππ = π1 β¦ {Person}, π2 β¦ {Person} ππ = π1 β¦ knows
π = (π1 , ππππ) β¦ {βAliceβ} (π2 , π πππ π‘ππππ) β¦ {βRobertβ, βJuliusβ}
(π2 , πππ π‘ππππ) β¦ {βSmithβ} (π1 , ππππ‘ππππ‘π¦) β¦ {0.5}
Figure 4 presents a possible visualization of a property graph.
We define a ShEx extension called PShEx that can be used to describe and validate Property
graphs. In property graphs, nodes and edges can have associated labels as well as a set of
property/values. In this way, it is necessary to adapt the definition of ShEx to describe pairs
or property/values. PShEx is composed of three main categories: shape expressions (π π) that
3
https://neo4j.com/
4
https://janusgraph.org/
5
https://www.sparsity-technologies.com/#sparksee
Human
Human
firstname: Robert, Julius
name: Alice n1 r1 n2
lastname: Smith
knows
certainty: 0.5
Figure 4: Example graph visualization of a property graph
describe the shape of nodes, triple expressions (π‘π) that describe the shape of edge relationships
and property-value expressions (ππ£π ) that describe sets of property/values associated with
node/edge identifiers.
Definition 5 (PShEx schema). A PShEx Schema is a tuple β¨L, πΏβ© where L set of shape labels, and
πΏ βΆ L β S is a total function from labels to shape expressions π π β S defined using the abstract
syntax:
π π ::= πππππ‘π Basic boolean condition on set of types π‘π β T
| π π1 AND π π2 Conjunction
| @l Shape label reference for l β L
| ππ£π Property-value specifiers of a node
| CLOSED {π‘π} Closed shape
| {π‘π} Open shape
π‘π ::= π‘π1 ; π‘π2 Each of π‘π1 and π‘π2
| π‘π1 β£ π‘π2 Some of π‘π1 or π‘π2
| π‘πβ Zero or more π‘π
π
| β
β @l ππ£π Triple constraint with property type π
whose nodes satisfy the shape l and property-values ππ£π
ππ£π ::= βππ β Open property-value specifiers ππ
| βππ β Closed property-value specifiers ππ
ππ ::= ππ 1 , ππ 2 Each of ππ 1 and ππ 2
| ππ 1 β£ ππ 2 OneOf of ππ 1 or ππ 2
| ππ β zero of more ππ
| π βΆ πππππ£ Property π with value conforming to πππππ£
πππππ£π is a boolean condition on sets of values π£π β V
Example 9. As an example, we can define a PShEx schema that describes the property graph
from example 8 where βππ π π¦πππ‘ is a condition that is satisfied when the set of types of a node
contains the type π‘, i.e. βππ π π¦πππ‘ (π£π ) = true if π‘ β π£π and ππ‘ππππ, π·ππππππ are conditions on the
values that are satisfied when the values have the corresponding type.
L = { ππππ ππ}
πΏ(ππππ ππ) = βππ π π¦πππ» π’πππ AND
βππππ βΆ ππ‘ππππ β£ π πππ π‘ππππ βΆ ππ‘ππππβ , πππ π‘ππππ βΆ ππ‘ππππβ AND
ππππ€π
{ ββββββ @ππππ ππ βππππ‘ππππ‘π¦ βΆ π·ππππππβ* }
In order to define the semantic specification of PShEx we will need to define the neighborhood
of a node in a property graph.
The neighbors of a node π β N in a property graph G = β¨N , E, π, ππ , ππ , π β© are defined as
ππππβπ (π) = {(π, π, π¦, π£π ) β£ βπ£ β E such that π(π£) = (π, π¦) β§ ππ (π£) = π β§ π£π = {(π, π£) β£ π (π, π£) =
π€π β§ π£ β π€π }}. For a node π, we define the property value set as πππππ£π (π) = {(π, π£) β£ π (π, π£) =
π€π β§ π£ β π€π }
The semantic specification of PShEx can be defined in a similar way to the ShEx one. Given
a property graph G, and a shape assignment π, a node identifier π β N conforms with a shape
expression π π, which is represented as G, π, π β¨ π π and follows the rules presented in 5 where
πππππ (π‘π) is the set of edge labels (or predicates) that appear in a triple expression π‘π and can be
defined as:
ππ (π) = π£π πππππ‘π (π£π ) = π‘ππ’π G, π, π β¨ π π1 G, π, π β¨ π π2
πΆππππ‘π π΄π π·
G, π, π β¨ πππππ‘π G, π, π β¨ π π1 AND π π2
ππππβπ (π, G) = π‘π G, π‘π , π β© π β²
πΆπππ πππβπππ
G, π, π β¨ CLOSED {π‘π}
π‘π = {β¨π₯, π, π¦β© β ππππβπ (π, G) β£ π β πππππ (π‘π)} G, π‘π , π β© π‘π
πππππβπππ
G, π, π β¨ {π‘π}
πΏ(l) = π π G, π, π β¨ π π πππππ£π (π) = π G, π , π β’ ππ£π
πβππππ
ππ ππ π
G, π, π β¨ @π G, π, π β¨ ππ£π
Table 5
Rules for PShEx shape expressions
πππππ (π‘π1 ; π‘π2 ) = πππππ (π‘π1 ) βͺ πππππ (π‘π2 )
πππππ (π‘π1 β£ π‘π2 ) = πππππ (π‘π1 ) βͺ πππππ (π‘π2 )
π
πππππ ( β β π‘π) = {π}
πππππ (π‘πβ) = πππππ (π‘π)
πππππ (π) = β
As in the case of ShEx, the previous definition uses a second conformance relation defined
on sets of triples π‘π instead of nodes π. The set of neighborhood nodes π‘π from a property graph
G conforms to a triple expression π‘π with shape assignment π, written G, π‘π , π β© π , as defined by
the inference rules represented in table 6.
In the case of PShEx we declare a new conformance relationship G, π , π β’ ππ between a graph
G a set π β π Γ π of property-value elements, a shape assignment π and a property-value specifier
ππ£π whose rules are defined in table 7 where πππππ (ππ£π ) is the set of properties that appear in a
property-value specifier ππ and can be defined as:
πππππ (ππ 1 , ππ 2 ) = πππππ (ππ 1 ) βͺ πππππ (ππ 2 )
πππππ (ππ 1 β£ ππ 2 ) = πππππ (ππ 1 ) βͺ πππππ (ππ 2 )
πππππ (ππ β) = πππππ (ππ )
πππππ (π βΆ πππππ£ ) = {π}
As in the case of ShEx, the semantics of ShEx schemas can be defined independently on shape
assignments. A shape assignment π for graph G and S is called valid if for every node π in G
and every shape expression label l defined in S, if π@l β π, then G, π, π β¨ @l.
(π‘π 1 , π‘π 2 ) β ππππ‘(π‘π ) G, π‘π 1 , π β© π‘π1 G, π‘π 2 , π β© π‘π2
πΈππβππ
G, π‘π , π β© π‘π1 ; π‘π2
G, π‘π , π β© π‘π1 G, π‘π , π β© π‘π2
πππππ1 πππππ2
G, π‘π , π β© π‘π1 β£ π‘π2 G, π‘π , π β© π‘π1 β£ π‘π2
π‘π = {β¨π₯, π, π¦, π β©} G, π¦, π β¨ @l G, π , π β’ ππ
π ππππππΆπππ π‘πππππ‘
π
G, π‘π , π β© β
β @l ππ
ππ‘ππ1
G, β
, π β© π‘πβ
(π‘π 1 , π‘π 2 ) β ππππ‘(π‘π ) G, π‘π 1 , π β© π‘π G, π‘π 2 , π β© π‘πβ
ππ‘ππ2
G, π‘π , π β© π‘πβ
Table 6
Rules for PShEx triple expressions
π β² = {(π, π£) β π |π β πππππ (ππ )} G, π β² , π β’ ππ G, π , π β’ ππ
ππππππ π πΆπππ πππ π
G, π , π β’ βππ β G, π , π β’ βππ β
G, π , π β’ ππ 1 G, π , π β’ ππ 2
πΈππβππ ππ
G, π , π β’ ππ 1 , ππ 2
G, π , π β’ ππ 1 G, π , π β’ ππ 2
πππππ ππ 1 πππππ ππ 2
G, π , π β’ ππ 1 β£ ππ 2 G, π , π β’ ππ 1 β£ ππ 2
(π 1 , π 2 ) β ππππ‘(π ) G, π 1 , π β’ ππ G, π 2 , π β’ ππ β
ππ‘ππππ 1 ππ‘ππππ 2
G, β
, π β’ ππ β G, π , π β’ ππ β
π = {(π, π€)} ππππ£π£ (π€) = true
πππππππ‘π¦π πππ’π
G, π , π β’ π βΆ πππππ£
Table 7
Rules for PShEx property-value specifiers
6. Related work
ShEx was initially proposed in 2014 [2] as a concise and human readable language to describe
and validate RDF. It was based on a variant of regular expressions called Regular Bag Expres-
sions [12] which also supports recursive shapes. Combining negation with recursive shapes
was later studied in [9] where a well founded formal semantics for ShEx for proposed based
on stratification. Our definition of ShEx is based on that work, although we omitted negation,
disjunction and EXTRA declarations of shape expressions in this paper. After ShEx was pro-
posed, a W3C Data Shapes working group was chatered whose result was SHACL, proposed
as a recommendation in 2017 [3]. The specification of SHACL didnβt have an abstract syntax
and left the semantics of recursive shapes as an implementation dependent feature enabling the
appearance of several proposals that define an abstract syntax and add semantics for SHACL
with negation and recursion [13, 14, 15, 16]. A comparison between both ShEx and SHACL was
provided in [17] while in [18], a simple language was defined that can be used as a common
subset of both. We consider that some of our extensions to ShEx could also be applied to SHACL.
The approach followed in this paper to extend ShEx was started in this paper [19] where we
had already proposed an initial version of PShEx and WShEx [20], another extension of ShEx to
support the Wikibase data model. WShEx is conceptually similar to PShEx although a distinct
feature of the Wikidbase data model is that the values of properties can also be nodes in the
graph, which can be considered as a generalized property graphs model. This model was called
MARS (Multi-Attributed Relational Structures) in [21].
There are several proposals for property graphs schemas. GQL is an upcoming ISO standard
(ISO39075) 6 which is currently being developed and addresses the property graph model. In
order to provide support for GQL, PG-Schema [22] was proposed as a simple schema language
for property graphs. PG-Schema does not support cardinality constraints on edges, which
could be simulated using PG-Keys [23]. In [24], the authors propose a common framework for
property graph schema languages based on first order logic rules which supports cardinality
constraints. The closest proposal to PShEx would be the Property Graph Shapes Language
(ProGS) [11] although that language is based on SHACL and some of the differences SHACL
vs ShEx could also be applied to ProGS vs PShEx. For example, PShEx doesnβt have property
path expressions and ProGS doesnβt have regular bag expressions. Another difference is that
ProGS includes negation and recursion while in the version of PShEx included in this paper we
omitted negation. Comparison between RDF-Star and property graphs at the data model have
already been studied. In [25] proposes a common model for RDF, RDF-Star and property graphs
that they call statement graph, which is inspired by the OneGraph [26] vision. The conversion
between property graphs and RDF/RDF-Star is also studied in [6].
7. Conclusions and future work
We have presented three extensions to ShEx for different types of knowledge graphs: ShEx-*
adds support for RDF-Star, ShEx-N adds a constraint to describe nodes that act as properties,
and PShEx can be used to describe and validate property graphs. We presented an abstract
syntax and formal semantics for each of the variants.
There are several lines of future work. On the theoretical level, it will be necessary to research
the computational complexity implications of these features as well as the combination of these
features with other features from ShEx like negation, disjunction, EXTRA declarations, and even
the potential integration of all the features together in a single language. On the implementation
level: it will be necessary to propose a concrete compact syntax for each variant that can be
useful by data model engineers as well as devise algorithms that can be used to check the
conformance of graphs to the corresponding schemas. Although we used ShEx in this paper,
another line of future work would be to check which of the features proposed in this paper
could also be applied to SHACL.
6
https://www.iso.org/standard/76120.html
Acknowledgments
This work has been partially funded by the Project ANGLIRU: ANGLIRU: Applying kNowledge
Graphs to research data interoperabiLIty and ReUsability, code: PID2020-117912RB. The discus-
sions held during our participation in Dagstuhl seminar 24102 Shapes in graph data: theory
and implementation helped us to write some of the ideas included in this paper.
References
[1] A. Hogan, E. Blomqvist, M. Cochez, C. dβAmato, G. de Melo, C. GutiΓ©rrez, S. Kirrane,
J. E. Labra Gayo, R. Navigli, S. Neumaier, A.-C. Ngonga Ngomo, A. Polleres, S. M. Rashid,
A. Rula, L. Schmelzeisen, J. F. Sequeda, S. Staab, A. Zimmermann, Knowledge Graphs,
number 22 in Synthesis Lectures on Data, Semantics, and Knowledge, Springer, 2021. URL:
https://kgbook.org/. doi:10.2200/S01125ED1V01Y202109DSK022 .
[2] E. Prudβhommeaux, J. E. Labra Gayo, H. Solbrig, Shape Expressions: An RDF Validation
and Transformation Language, in: H. Sack, A. Filipowska, J. Lehmann, S. Hellmann (Eds.),
Proceedings of the 10th International Conference on Semantic Systems, SEMANTICS
2014, Leipzig, Germany, September 4-5, 2014, ACM Press, 2014, pp. 32β40. doi:10.1145/
2660517.2660523 .
[3] H. Knublauch, D. Kontokostas, Shapes Constraint Language (SHACL), W3C Recommen-
dation 20 July 2017, W3C Recommendation, World Wide Web Consortium, 2017. URL:
https://www.w3.org/TR/2017/REC-shacl-20170720/.
[4] R. Cyganiak, D. Wood, M. Lanthaler, RDF-star and SPARQL-star, Draft Community Group
Report, World Wide Web Consortium, 2021. URL: https://w3c.github.io/rdf-star/cg-spec.
[5] O. hartig, P.-A. Champin, G. Kellogg, A. Seaborne, RDF 1.2 Concepts and Abstract Syntax,
W3C Working Draft, World Wide Web Consortium, 2024. URL: https://www.w3.org/TR/
rdf12-concepts/.
[6] S. Khayatbashi, S. Ferrada, O. Hartig, Converting property graphs to rdf: a preliminary
study of the practical impact of different mappings, in: Proceedings of the 5th ACM
SIGMOD Joint International Workshop on Graph Data Management Experiences and
Systems (GRADES) and Network Data Analytics (NDA), SIGMOD/PODS β22, ACM, 2022.
doi:10.1145/3534540.3534695 .
[7] I. Boneva, J. E. Labra Gayo, E. G. Prudβhommeaux, Semantics and Validation of Shapes
Schemas for RDF, in: C. dβAmato, M. FernΓ‘ndez, V. A. M. Tamma, F. LΓ©cuΓ©, P. CudrΓ©-
Mauroux, J. F. Sequeda, C. Lange, J. Heflin (Eds.), The Semantic Web - ISWC 2017 - 16th
International Semantic Web Conference, Vienna, Austria, October 21-25, 2017, Proceedings,
Part I, volume 10587 of Lecture Notes in Computer Science, Springer, 2017, pp. 104β120.
[8] E. Prudβhommeaux, I. Boneva, J. E. Labra Gayo, G. Kellog, Shape Expressions Language
2.0, 2017. URL: https://shexspec.github.io/spec/.
[9] I. Boneva, J. E. Labra Gayo, E. Prudβhommeaux, Semantics and validation of shapes schemas
for rdf, in: International Semantic Web Conference, 2017.
[10] O. Hartig, Foundations of RDF* and SPARQL* β An Alternative Approach to Statement-
Level Metadata in RDF, in: J. L. Reutter, D. Srivastava (Eds.), Proceedings of the 11th
Alberto Mendelzon International Workshop on Foundations of Data Management and the
Web, Montevideo, Uruguay, June 7-9, 2017, volume 1912 of CEUR Workshop Proceedings,
Sun SITE Central Europe (CEUR), 2017. URL: http://ceur-ws.org/Vol-1912/paper12.pdf.
[11] P. Seifer, R. LΓ€mmel, S. Staab, ProGS: Property Graph Shapes Language, in: International
Semantic Web Conference, volume 12922, Springer, 2021, pp. 392β401. doi:https://doi.
org/10.1007/978- 3- 030- 88361- 4_23 . arXiv:2107.05566 .
[12] S. Staworko, I. Boneva, J. E. Labra Gayo, S. Hym, E. G. Prudβhommeaux, H. R. Solbrig,
Complexity and Expressiveness of ShEx for RDF, in: 18th International Conference on
Database Theory, ICDT 2015, volume 31 of LIPIcs, Schloss Dagstuhl - Leibniz-Zentrum
fuer Informatik, 2015, pp. 195β211.
[13] J. Corman, J. L. Reutter, O. SavkoviΔ, Semantics and Validation of Recursive SHACL,
in: D. VrandeΔiΔ, K. Bontcheva, M. C. SuΓ‘rez-Figueroa, V. Presutti, I. Celino, M. Sabou,
L. Kaffee, E. Simperl (Eds.), The Semantic Web - ISWC 2018 - 17th International Semantic
Web Conference, Monterey, CA, USA, October 8-12, 2018, Proceedings, Part I, volume
11136 of Lecture Notes in Computer Science, Springer, 2018, pp. 318β336.
[14] M. Andresel, J. Corman, M. Ortiz, J. L. Reutter, O. Savkovic, M. Simkus, Stable model
semantics for recursive shacl, in: Proceedings of The Web Conference 2020, WWW β20,
ACM, 2020. doi:10.1145/3366423.3380229 .
[15] B. Bogaerts, M. Jakubowski, Fixpoint semantics for recursive SHACL, in: A. Formisano, Y. A.
Liu, B. Bogaerts, A. Brik, V. Dahl, C. Dodaro, P. Fodor, G. L. Pozzato, J. Vennekens, N. Zhou
(Eds.), Proceedings 37th International Conference on Logic Programming (Technical Com-
munications), ICLP Technical Communications 2021, Porto (virtual event), 20-27th Septem-
ber 2021, volume 345 of EPTCS, 2021, pp. 41β47. URL: https://doi.org/10.4204/EPTCS.345.14.
doi:10.4204/EPTCS.345.14 .
[16] A. Chmurovic, M. Ε imkus, Well-founded semantics for recursive shacl, in: CEUR Workshop
Proceedings :, number 3203 in CEUR Workshop proceedings, 2022, pp. 2β13. URL: http:
//ceur-ws.org/Vol-3203/.
[17] J. E. Labra Gayo, E. Prudβhommeaux, I. Boneva, D. Kontokostas, Validating RDF Data,
volume 7 of Synthesis Lectures on the Semantic Web: Theory and Technology, Morgan &
Claypool, 2017. URL: https://doi.org/10.2200/s00786ed1v01y201707wbe016. doi:10.2200/
s00786ed1v01y201707wbe016 .
[18] J. E. Labra Gayo, H. GarcΓa-GonzΓ‘lez, D. FernΓ‘ndez-Alvarez, E. Prudβhommeaux, Challenges
in RDF Validation, in: G. Alor-HernΓ‘ndez, J. L. SΓ‘nchez-Cervantes, A. RodrΓguez-GonzΓ‘lez,
R. Valencia-GarcΓa (Eds.), Current Trends in Semantic Web Technologies: Theory and
Practice, Studies in Computational Intelligence, Springer, 2019, pp. 121β151. doi:10.1007/
978- 3- 030- 06149- 4_6 .
[19] J. E. L. Gayo, Creating knowledge graphs subsets using shape expressions, 2021.
arXiv:2110.11709 .
[20] J.-E. Labra-Gayo, Wshex: A language to describe and validate wikibase entities, in:
L. Kaffee, S. Razniewski, G. Amaral, K. S. Alghamdi (Eds.), Proceedings of the 3rd Wiki-
data Workshop 2022 co-located with the 21st International Semantic Web Conference
(ISWC2022), Virtual Event, Hanghzou, China, October 2022, volume 3262 of CEUR Work-
shop Proceedings, CEUR-WS.org, 2022. URL: https://ceur-ws.org/Vol-3262/paper3.pdf.
[21] M. Marx, M. KrΓΆtzsch, V. Thost, Logic on MARS: ontologies for generalised property
graphs, in: C. Sierra (Ed.), Proceedings of the 26th International Joint Conference on
Artificial Intelligence (IJCAIβ17), International Joint Conferences on Artificial Intelligence,
2017, pp. 1188β1194. doi:10.24963/ijcai.2017/165 .
[22] R. Angles, A. Bonifati, S. Dumbrava, G. Fletcher, A. Green, J. Hidders, B. Li, L. Libkin,
V. Marsault, W. Martens, F. Murlak, S. Plantikow, O. Savkovic, M. Schmidt, J. Sequeda,
S. Staworko, D. Tomaszuk, H. Voigt, D. Vrgoc, M. Wu, D. Zivkovic, Pg-schema: Schemas
for property graphs, Proceedings of the ACM on Management of Data 1 (2023) 1β25.
doi:10.1145/3589778 .
[23] R. Angles, A. Bonifati, S. Dumbrava, G. Fletcher, K. W. Hare, J. Hidders, V. E. Lee, B. Li,
L. Libkin, W. Martens, F. Murlak, J. Perryman, O. SavkoviΔ, M. Schmidt, J. Sequeda,
S. Staworko, D. Tomaszuk, Pg-keys: Keys for property graphs, in: Proceedings of
the 2021 International Conference on Management of Data, SIGMOD/PODS β21, ACM,
2021. doi:10.1145/3448016.3457561 .
[24] N. Beeren, G. Fletcher, A formal design framework for practical property graph
schema languages, in: J. Stoyanovich, J. Teubner, N. Mamoulis, E. Pitoura, J. MΓΌhlig,
K. Hose, S. S. Bhowmick, M. Lissandrini (Eds.), Proceedings 26th International Confer-
ence on Extending Database Technology, EDBT 2023, Ioannina, Greece, March 28-31,
2023, OpenProceedings.org, 2023, pp. 478β484. URL: https://doi.org/10.48786/edbt.2023.40.
doi:10.48786/EDBT.2023.40 .
[25] E. Gelling, G. Fletcher, M. Schmidt, Bridging graph data models: Rdf, rdf-star, and property
graphs as directed acyclic graphs, CoRR abs/2304.13097 (2023). URL: https://doi.org/10.
48550/arXiv.2304.13097. doi:10.48550/ARXIV.2304.13097 . arXiv:2304.13097 .
[26] O. Lassila, M. Schmidt, O. Hartig, B. Bebee, D. Bechberger, W. Broekema, A. Khandelwal,
K. Lawrence, C. M. Lopez Enriquez, R. Sharda, B. Thompson, The onegraph vision:
Challenges of breaking the graph model lock-in1, Semantic Web 14 (2022) 125β134.
doi:10.3233/sw- 223273 .