W3C home > Mailing lists > Public > public-data-shapes-wg@w3.org > January 2015

Re: example of recursive shapes

From: Holger Knublauch <holger@topquadrant.com>
Date: Sun, 25 Jan 2015 10:35:40 +1000
Message-ID: <54C43A5C.2080307@topquadrant.com>
To: public-data-shapes-wg@w3.org
ex:Polentoni
     a rdfs:Class ; # or ldom:Shape, or nothing
     ldom:constraint [
         ldom:sparql """
             ASK {
                 FILTER NOT EXISTS {
                     ?this ex:livesIn ex:NorthernItaly
                 }
             }"""
         ldom:predicate ex:
     ] ;
     ldom:constraint [
         a ldom:ShapeConstraint ;
         ldom:predicate ex:knows ;
         ldom:all ex:Polentoni ;
     ] .

The evaluation is started using the built-in function

     ldom:violatesConstraints(ex:Enrico, ex:Polontoni)

The function checks if the given instance fulfills all constraints for 
the given class. The implementation of ldom:all recursively calls 
ldom:violatesConstraints. (The engine needs to make sure it doesn't run 
into infinite loops, so this requires work).

(This example also indicates that we should have a template for the 
owl:hasValue equivalent, so that people don't need to write the ugly 
SPARQL. I will add such a thing).

Does this address your use case?

Holger




On 1/25/15, 3:18 AM, Peter F. Patel-Schneider wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Here is an example of recursive shapes and constraints based on them.  I
> have purposefully removed typing information and domains and ranges from the
> RDF graph given at the beginning.  A version of the RDF graph that is more
> likely to actually occur is given at the end.  The extra information does
> not change anything.
>
>
> Reduced RDF Graph
>
> ex:Enrico ex:livesIn ex:NorthernItaly .
> ex:Diego ex:livesIn  ex:NorthernItaly .
> ex:Alessandro ex:livesIn ex:NorthernItaly .
> ex:Sergio ex:livesIn ex:NorthernItaly .
> ex:John ex:livesIn ex:NorthernItaly .
> ex:Maurizio ex:livesIn ex:SouthernItaly .
>
> ex:Enrico ex:knows ex:John .
> ex:John ex:knows ex:Maurizio .
> ex:Diego ex:knows ex:Alessandro .
> ex:Alessandro ex:knows ex:Diego .
> ex:Alessandro ex:knows ex:Sergio
>
>
> Shapes and Constraints (informal)
>
> Polentoni are those who live in Northern Italy and who only know those who
> are Polentoni.  Enrico is not Polentoni.  Diego is Polentoni.
>
>
> Shapes and Constraints (in OWL Constraints with Closed-World Recognition)
>
> Polentoni = (ex:livesIn : ex:NorthernItaly) & (all ex:knows Polentoni)
> ex:Enrico not in Polentoni
> ex:Diego in Polentoni
>
>
> Shapes and Constraints (in ShExC plus OSLC controls)
>
> <Polentoni> {
>     ex:livesIn ( ex:NorthernItaly ),
>     ex:knows @<Polentoni>*
> }
>
> ex:Diego oslc:instanceShape <Polentoni> .
>
> I don't believe that this setup can require that Enrico is not Polentoni.
>
>
> Natural RDF Graph
>
> ex:Person rdf:type rdfs:Class .
> ex:Region rdf:type rdfs:Class .
> ex:livesIn rdf:type rdf:Property .
> ex:knows rdf:type rdf:Property .
> ex:livesIn rdfs:domain ex:Person .
> ex:livesIn rdfs:range ex:Region .
> ex:knows rdfs:domain ex:Person .
> ex:knows rdfs:range ex:Person .
>
> ex:NorthernItaly rdf:type ex:Region .
> ex:SouthernItaly rdf:type ex:Region .
>
> ex:Enrico rdf:type ex:Person .
> ex:Diego rdf:type ex:Person .
> ex:Alessandro rdf:type ex:Person .
> ex:Sergio rdf:type ex:Person .
> ex:John rdf:type ex:Person .
> ex:Maurizio rdf:type ex:Person .
>
> ex:Enrico ex:livesIn ex:NorthernItaly .
> ex:Diego ex:livesIn  ex:NorthernItaly .
> ex:Alessandro ex:livesIn ex:NorthernItaly .
> ex:Sergio ex:livesIn ex:NorthernItaly .
> ex:John ex:livesIn ex:NorthernItaly .
> ex:Maurizio ex:livesIn ex:SouthernItaly .
>
> ex:Enrico ex:knows ex:John .
> ex:John ex:knows ex:Maurizio .
> ex:Diego ex:knows ex:Alessandro .
> ex:Alessandro ex:knows ex:Diego .
> ex:Alessandro ex:knows ex:Sergio
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
>
> iQEcBAEBAgAGBQJUw9PxAAoJECjN6+QThfjzY8sH/0muw9K1qvzlYK5BUbiqKErm
> gP7+lcMmwHvNUhbsUQzoiI2bvcM3VMKJSOB7E3xfflC1W3GY1JBqz2NvQzsnIpjF
> Bw+axcbYcRxHG+zvoQcHuEAJUlT1n0U/iTTS/DxnzEEBhaBL2qXsB5UrQnTwpW/W
> MfoFX6ZC+ZhSpuI0NL0IbrJ2Hw+f3T5f+apTfGTUvvIFfurURSVjukNPXYhKN6KQ
> X/CjL4CJDYFhVPuQE9JFUyB3vSKZUCSfZKL2RNMLdu1cKh3wcUrO+qGYyCoC3JB1
> lC2Am0NB0sk+Fdw1P2AO9cjuk/tURx8yF1qK3YHp+amZYvySJZ6wHCL5ijcBnyI=
> =MSHG
> -----END PGP SIGNATURE-----
>
Received on Sunday, 25 January 2015 00:36:12 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 25 January 2015 00:36:12 UTC