Re: question on on shacl semantics

On 9/14/2015 23:38, Peter F. Patel-Schneider wrote:
> The syntax for constraint combination is a bit peculiar at the moment.
>
> To get the effect you want you need two (or more) separate property
> constraints, but to get the effect in Example 22 you can use either one or two
> property constraints.  If you use two property constraints for Example 22,
> then the road to your example may be clearer.
>
> So here is the alternative shape for Example 22
>
> ex:QualifiedValueShapeExampleShape
>    a sh:Shape ;
>    sh:property [
>      sh:predicate ex:parent ;
>      sh:minCount 2 ;
>      sh:maxCount 2 ] ;
>    sh:property [[

This isn't valid Turtle. One [ would be correct.

It is also unclear from Iovka's email whether she wanted to make sure 
that the male and the female node must be distinct nodes in the graph. 
Your solution would still allow them to be the same instance unless you 
have another constraint that maxCount of gender is 1.

Anyway, under the above assumptions here is a solution using SPARQL 
(untested):

ex:QualifiedValueShapeExampleShape
     a sh:Shape ;
     sh:property [
         sh:predicate ex:parent ;
         sh:maxCount 2 ;
     ] ;
     sh:constraint [
         sh:sparql """
             SELECT $this
             WHERE {
                 FILTER NOT EXISTS {
                     $this ex:parent ?father .
                     $this ex:parent ?mother .
                     FILTER (?father != ?mother) .
                     ?father ex:gender ex:male .
                     ?mother ex:gender ex:female .
                 }
             }"""
     ] .

which ticks other boxes than a pure SHACL solution would.

HTH
Holger


>      sh:predicate ex:parent ;
>      sh:qualifiedValueShape [
>        a sh:Shape ;
>        sh:property [
>  sh:predicate ex:gender ;
>  sh:hasValue ex:female ] ] ;
>      sh:qualifiedMinCount 1 ] .
>
> Your example is then
>
> ex:QualifiedValueShapeExampleShape
>    a sh:Shape ;
>    sh:property [
>      sh:predicate ex:parent ;
>      sh:minCount 2 ;
>      sh:maxCount 2 ] ;
>    sh:property [[
>      sh:predicate ex:parent ;
>      sh:qualifiedValueShape [
>        a sh:Shape ;
>        sh:property [
>          sh:predicate ex:gender ;
>          sh:hasValue ex:female ] ] ;
>      sh:qualifiedMinCount 1 ] ;
>   sh:property [[
>      sh:predicate ex:parent ;
>      sh:qualifiedValueShape [
>        a sh:Shape ;
>        sh:property [
>          sh:predicate ex:gender ;
>          sh:hasValue ex:male ] ] ;
>      sh:qualifiedMinCount 1 ] .
>
> peter
>
> PS:  This split-piling-on syntax for property constraints is similar to the
> early syntaxes for OWL that still lives on in OWL Full.
>
>
> On 09/14/2015 12:42 AM, Iovka Boneva wrote:
>> Thank you for your answers.
>> Here is another question.
>>
>> Quoting the current version of the spec:
>>
>> // open quote
>>
>> In the following example, the property |ex:parent| must have exactly two values,
>> and at least one of them needs to be female.
>>
>>
>> Example 22: Shape with sh:valueShape constraint
>>
>> ex:QualifiedValueShapeExampleShape
>>  a sh:Shape ;
>>  sh:property [
>>   sh:predicate ex:parent ;
>>   sh:minCount 2 ;
>>   sh:maxCount 2 ;
>>   sh:qualifiedValueShape [
>>    a sh:Shape ;   # Optional
>>    sh:property [
>>     sh:predicate ex:gender ;
>>     sh:hasValue ex:female ;
>>    ]
>>   ] ;
>>   sh:qualifiedMinCount 1 ;
>>  ] .
>>
>> ex:QualifiedValueShapeExampleValidResource
>>  ex:parent ex:John ;
>>  ex:parent ex:Jane .
>>
>> ex:John
>>  ex:gender ex:male .
>>
>> ex:Jane
>>  ex:gender ex:female .
>>
>> // close quote
>>
>> Now my question is: how to specify that there are exactly two parents, exactly
>> one is female and exactly one is male.
>>
>> Thanks in advance,
>> Iovka
>>
>>
>>
>>
>> Le 09/09/2015 14:56, Peter F. Patel-Schneider a écrit :
>>> These all correspond to my understanding of the current state of SHACL.
>>>
>>> Closure is with respect to properties that explicitly appear in top-level
>>> property constraints.  You can fiddle with this by adding in vacuous
>>> constraints for the other properties or by using sh:ignoredProperties.
>>> See http://w3c.github.io/data-shapes/shacl/#ClosedShape for more information.
>>>
>>> peter
>>>
>>> On 09/09/2015 05:41 AM, Simon Steyskal wrote:
>>>> Hi!
>>>>
>>>> I've tested it with TBC (there might have been some changes to SHACL that
>>>> haven't been implemented in TBC yet):
>>>>
>>>> 1) fails -> 2x "Invalid triple for closed shape", one for ex:a "value1"; and
>>>> one for ex:b "value2";
>>>> 2) fails -> 1x "Invalid triple for closed shape", for ex:b "value2";
>>>> 3) no, doesn't constrain anything
>>>>
>>>> cheers,
>>>> simon
>>>>
>>>> ---
>>>> DDipl.-Ing. Simon Steyskal
>>>> Institute for Information Business, WU Vienna
>>>>
>>>> www: http://www.steyskal.info/  twitter: @simonsteys
>>>>
>>>> Am 2015-09-09 14:29, schrieb Iovka Boneva:
>>>>> Dear all,
>>>>>
>>>>> I'm trying to clarify (for myself) the SHACL semantics.
>>>>>
>>>>> Here are three examples, can somebody please tell me whether these
>>>>> examples pass or fail for the corresponding data.
>>>>>
>>>>> Thanks in advance,
>>>>> Iovka
>>>>>
>>>>> // Example 1: is the ex:Instance node valid for that shape ?
>>>>>
>>>>> ex:ClosedShapeExampleShape
>>>>>      a sh:Shape ;
>>>>>      sh:constraint [
>>>>>          a sh:ClosedShapeConstraint ;
>>>>>      ] ;
>>>>>             sh:constraint [
>>>>>          a sh:OrConstraint ;
>>>>>          sh:shapes (
>>>>>              [
>>>>>                  sh:property [
>>>>>                      sh:predicate ex:a ;
>>>>>                      sh:minCount 1 ;
>>>>>                  ]
>>>>>              ]
>>>>>              [
>>>>>                  sh:property [
>>>>>                      sh:predicate ex:b ;
>>>>>                      sh:minCount 1 ;
>>>>>                  ]
>>>>>              ]
>>>>>          )
>>>>>      ] ;
>>>>>      sh:property [
>>>>>          sh:predicate ex:c ;
>>>>>      ] .
>>>>>
>>>>>
>>>>> ex:Instance
>>>>>      ex:a "value1";
>>>>>      ex:b "value2";
>>>>>      ex:c "value3";
>>>>>
>>>>> __________________________
>>>>>
>>>>> // Example 2: is the ex:Instance node valid for that shape ?
>>>>>
>>>>> ex:ClosedShapeExampleShape
>>>>>      a sh:Shape ;
>>>>>      sh:constraint [
>>>>>          a sh:ClosedShapeConstraint ;
>>>>>      ] ;
>>>>>             sh:constraint [
>>>>>          a sh:OrConstraint ;
>>>>>          sh:shapes (
>>>>>              [
>>>>>                  sh:property [
>>>>>                      sh:predicate ex:a ;
>>>>>                      sh:maxCount 0 ;
>>>>>                  ]
>>>>>              ]
>>>>>              [
>>>>>                  sh:property [
>>>>>                      sh:predicate ex:b ;
>>>>>                      sh:minCount 1 ;
>>>>>                  ]
>>>>>              ]
>>>>>          )
>>>>>      ] ;
>>>>>      sh:property [
>>>>>          sh:predicate ex:a ;
>>>>>      ] ;
>>>>>      sh:property [
>>>>>          sh:predicate ex:c ;
>>>>>      ] .
>>>>>
>>>>>
>>>>> ex:Instance
>>>>>      ex:a "value1";
>>>>>      ex:b "value2";
>>>>>      ex:c "value3".
>>>>>
>>>>>
>>>>> ______________________
>>>>>
>>>>> // Example 3: Is this constraining something ? Is this valid for every node ?
>>>>>
>>>>> ex:AShape
>>>>>      a sh:Shape ;
>>>>>      sh:property [
>>>>>          sh:predicate ex:a ;
>>>>>      ] ;
>>>>>      sh:property [
>>>>>          sh:predicate ex:c ;
>>>>>      ] .
>>>>
>>
>>
>> -- 
>> Iovka Boneva
>> Associate professor (MdC) Université de Lille
>> http://www.cristal.univ-lille.fr/~boneva/
>> +33 6 95 75 70 25
>>

Received on Monday, 14 September 2015 20:27:46 UTC