W3C home > Mailing lists > Public > public-rdf-shapes@w3.org > November 2016

on removing pre-binding from the core of SHACL

From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
Date: Fri, 11 Nov 2016 19:27:06 -0800
To: "public-rdf-shapes@w3.org" <public-rdf-shapes@w3.org>
Message-ID: <47681b7c-5e9b-5f42-9257-0bea5a6b4ab1@gmail.com>
The specification of the core of SHACL uses a non-standard mechanism, namely
pre-binding.


For example class targets are specified as:


The following SPARQL query specifies the semantics of class targets. The
variable targetClass is assumed to be pre-bound to the given value of
sh:targetClass.

SELECT DISTINCT ?this    # ?this is the focus node
WHERE {
  ?this rdf:type/rdfs:subClassOf* $targetClass .    # $targetClass is
pre-bound to ex:Person
}


(Note that this wording needs to be significantly changed, as it currently
doesn't actually talk about how the query determines targets.)


The use of pre-binding is unnecessary here.  All that is required to remove
this use is to say instead:


The following SPARQL query specifies the semantics of class targets.  When
validating a data graph the set of targets for a value V of sh:targetClass
on a shape is the set of RDF nodes containing precisely the mappings of the
SPARQL variable target in the solution sets of the following SPARQL query
on the data graph that map the SPARQL variable targetClass to V.

SELECT ?target $targetClass
WHERE {
  ?this rdf:type/rdfs:subClassOf* $targetClass .
}



Pre-binding can be eliminated from constraint components that currently use
ASK queries via the following wording:

A value node V validates for sh:ClassConstraintComponent with value C for
parameter sh:class in a constraint if the following query returns a solution
mapping that maps the SPARQL variable value to V and the SPARQL variable
class to C.

SELECT $value $class {
	$value rdf:type/rdfs:subClassOf* $class .
}

This can also serve as the start of removing the dependency of core SPARQL
on full SPARQL.  What else is required is a SPARQL specification of how
value nodes are determined along the lines the following for path-based
property constraints.

The set of value nodes for a focus node F for a property constraint with
path P is the set of RDF nodes containing precisely the mappings of the
SPARQL variable value in solution mappings of the following SPARQL query
after path substition that map the SPARQL variable this to F.

SELECT $this $value
WHERE {
  ?this $PATH ?value .
}


Other constraint components require more changes from the current document.
Here is wording for sh:MinCountConstraintComponent.  I think queries and
wording for all core constraint components can be devised.

A focus node F validates for sh:MinCountConstraintComponent with value m for
parameter sh:minCount in a constraint if the following query after path
substitution returns a solution mapping that maps the SPARQL variable this
to F and the SPARQL variable count to a value no smaller than m, unless m is
less than or equal to 0 in which case every focus node validates.

SELECT $this ( COUNT ( DISTINCT ?value ) AS ?count )
WHERE {
  $this $PATH ?value .
}
GROUP BY $this


I believe that pre-binding can be completely removed from the specification of
the core of SHACL.


Peter F. Patel-Schneider
Nuance Communications
Received on Saturday, 12 November 2016 03:27:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:46 UTC