Re: shapes-ISSUE-168 (instance count): How to constrain number of instances of a class in a graph [SHACL - Core]

On Tue, Jun 14, 2016 at 3:18 AM, Holger Knublauch <holger@topquadrant.com>
wrote:

> Hi Dimitris,
>
> the body of this new constraint component would be something like
>
> SELECT $this
> WHERE {
>     ?instance rdf:type/rdfs:subClassOf* $this .
> } HAVING (COUNT(?instance) > $maxInstanceCount)
>
> The scope is generally binding the values of $this. So in order to make
> this work, most people would use sh:scopeNode to link to a class directly.
> Use cases for sh:scopeClass would be in the realm of metaclasses, or custom
> scopes such as "for all classes that have a given property"
> (sh:scopeProperty). (I hope this addresses your other questions below).
>

just to make it clear so we can also vote for this directly

when we have multiple scopes (that make sense)
sh:scopeNode schema:FlightReservation , schema:DinnerReservation ;
we get the union so we constraint to exactly 1 (schema:FlightReservation or
schema:DinnerReservation)

This needs to be clear as we didn't have any other constraint so far that
has a different behavior on if we treat all scopes together or one by one

when we have multiple scopes (that don't make sense)
sh:scopeClass foaf:Person
sh:scopeProperty ex:p

we always get an error, unless one of the focus nodes is used in rdf:type
statements

BTW if we merge Shape and NodeConstraint, as suggested, the syntax would
> look better:
>
> ex:MyShape
>     a sh:Shape ;
>     sh:scopeNode schema:FlightReservation ;
>     sh:maxInstanceCount 1 ;
>     sh:minInstanceCount 1 .
>

to me this resembles Peter's proposal which has a little different
semantics, I would rather use sh:node


> The general problem with scope-based constraints is that scopes are only
> one way to trigger validation. Other cases include nested shapes (sh:shape,
> sh:or etc) and (as in ShEx) to have some dedicated root shape or (as in
> Arthur's use cases, if I may speak on his behalf) control the validation
> process completely outside of the model, from some application-specific
> algorithm. So anything that behaves differently depending on whether it has
> a scope or not is bound to fail.
>

I do not think this is a problem but a feature, every constraint can have a
scope that is direct (sh:scope*), indirect (from sh:shape, sh:or etc) or
manual (from validation).
If we treat constraints & scopes like this everything becomes much simpler.

Dimitris

>
>
>
> On 14/06/2016 3:33, Dimitris Kontokostas wrote:
>
> Hi Holger,
>
> I think there is a typo in your example, it should be sh:scopeClass.
>
> For me it is fine to have this as syntactic sugar for Karen's use case but
> we need to be more precise on how this will work with scoping in general.
> Does this constraint apply on the union of all defined scopes or per
> defined scope ?
>
> e.g. consider this example
> ex:MyPersonShape
>     a sh:Shape ;
>     sh:scopeClass  ex:Doctor, ex:Patience ;
>     sh:scopeNode ex:DrWho, ex:Bob
>     sh:scopeProperty ex:operated
>     sh:scopeInverseProperty ex:operated
>     sh:constraint [
>         sh:minInstanceCount 1 ;
>         sh:maxInstanceCount 1 ;
>     ] .
>
> do we require 1 doctor, 1 Patience, 1 ...
> or only 1 of all together?
>
> Also, what would be the definition when this constraint is referenced from
> e.g. sh:shape?
> ex:MyHospitalShape
>    a sh:Shape
>    sh:scopeClass ex:Hospital
>    sh:property [
>        sh:predicate ex:personStayed
>        sh:shape ex:MyPersonShape
>   ]
>
> does the constraint apply an all hospitals with a property ex:personStayed
> ( ex:Hospital[ex:stayed]) ?
>
> Best
> Dimitris
>
> On Mon, Jun 13, 2016 at 3:04 PM, RDF Data Shapes Working Group Issue
> Tracker < <sysbot+tracker@w3.org>sysbot+tracker@w3.org> wrote:
>
>> shapes-ISSUE-168 (instance count): How to constrain number of instances
>> of a class in a graph [SHACL - Core]
>>
>> http://www.w3.org/2014/data-shapes/track/issues/168
>>
>> Raised by: Holger Knublauch
>> On product: SHACL - Core
>>
>> There was recent discussion about how to specify min/max numbers of
>> instances in a graph.  Off-list I had also received a question from
>> schema.org people about how to state that a graph/message must have
>> exactly one instance of schema:FlightReservation, possibly to ensure that a
>> graph has a starting point/root for validation.
>>
>> A possible syntax that would easily work with the current architecture
>> could be
>>
>> ex:MyShape
>>     a sh:Shape ;
>>     sh:scopeNode schema:FlightReservation ;
>>     sh:constraint [
>>         sh:minInstanceCount 1 ;
>>         sh:maxInstanceCount 1 ;
>>     ] .
>>
>>
>>
>>
>
>
> --
> Dimitris Kontokostas
> Department of Computer Science, University of Leipzig & DBpedia
> Association
> Projects: <http://dbpedia.org>http://dbpedia.org, http://rdfunit.aksw.org,
> <http://aligned-project.eu>http://aligned-project.eu
> Homepage:  <http://aksw.org/DimitrisKontokostas>
> http://aksw.org/DimitrisKontokostas
> Research Group: AKSW/KILT  <http://aksw.org/Groups/KILT>
> http://aksw.org/Groups/KILT
>
>
>


-- 
Dimitris Kontokostas
Department of Computer Science, University of Leipzig & DBpedia Association
Projects: http://dbpedia.org, http://rdfunit.aksw.org,
http://aligned-project.eu
Homepage: http://aksw.org/DimitrisKontokostas
Research Group: AKSW/KILT http://aksw.org/Groups/KILT

Received on Tuesday, 14 June 2016 04:31:51 UTC