Re: ISSUE-22: Proposal based on sh:hasShape

On 6/11/15 4:06 PM, Simon Steyskal wrote:
> Hi!
>
>> What am I missing?
>
> Although I still have to walk through all recent SHACL related mails I 
> was wondering if negation in combination with recursion was already 
> discussed? Without stratification, using negation within recursion may 
> lead to infinite loops..
In my proposal, infinite loops cannot happen, because there is a finite 
number of shapes and a finite number of resources to validate. As soon 
as the same node/shape combination is visited twice, it would stop 
gracefully.

This doesn't mean that your scenario would work with other implementations.

Holger


>
> I tried to come up with an example which illustrates that issue:
>
> ------------------------------------------------
> ex:recursionShapeExample
>    a sh:Shape ;
>    sh:property [
>       sh:predicate ex:someProperty ;
>       sh:valueShape ex:hasAShape)
>    ] .
>
> ex:hasAShape
>    a sh:Shape ;
>       sh:constraint [
>          a sh:AndConstraint ;
>          sh:shapes (ex:ValueTypeAShape ex:notBShape)
>       ] .
>
> ex:hasBShape
>    a sh:Shape ;
>       sh:constraint [
>          a sh:AndConstraint ;
>          sh:shapes (ex:ValueTypeBShape ex:notAShape)
>       ] .
>
> ex:notAShape
>    a sh:Shape ;
>    sh:constraint [
>       a sh:NotConstraint ;
>       sh:shape ex:hasAShape;
>    ] .
>
> ex:notBShape
>    a sh:Shape ;
>    sh:constraint [
>       a sh:NotConstraint ;
>       sh:shape ex:hasBShape;
>    ] .
>
> ex:ValueTypeAShape
>    a sh:Shape ;
>    sh:property [
>       sh:predicate ex:property ;
>       sh:valueType ex:ClassA ;
>    ] .
>
> ex:ValueTypeBShape
>    a sh:Shape ;
>    sh:property [
>       sh:predicate ex:property ;
>       sh:valueType ex:ClassB ;
>    ] .
>
> ------------------------------------------------
>
> Here recursionShapeExample states that the value of ex:someProperty 
> must be of shape ex:hasAShape. ex:hasAShape itself is defined as being 
> both an ex:ValueTypeAShape and ex:notBShape.
> Now it gets tricky.. ex:notBShape is defined as sh:NotConstraint of 
> ex:hasBShape, which itself is defined as the exact opposite, i.e. 
> being both an ex:ValueTypeBShape and ex:notAShape.
>
> Could this be relevant for recursive shapes?
>
> cheers,
> simon
>
> ---
> DDipl.-Ing. Simon Steyskal
> Institute for Information Business, WU Vienna
>
> www: http://www.steyskal.info/  twitter: @simonsteys
>
> Am 2015-06-11 03:11, schrieb Holger Knublauch:
>> I would like to write down the solution to the recursion issue that I
>> have currently implemented in my prototype, and welcome comments
>> whether this would resolve the issue.
>>
>> Recursive evaluation of shapes can only be triggered via the
>> sh:hasShape function. sh:hasShape takes three arguments:
>>
>>     sh:hasShape(?focusNode, ?shape, ?shapesGraph)
>>
>> Proposal: sh:hasShape must fail with a constraint violation, if it
>> encounters a recursive call involving the same combination of
>> arguments. The constraint violation could have a system generated
>> message such as "Failed to evaluate constraint due to unsupported
>> recursive use of sh:hasShape" and point at the focus node that was
>> visited twice.
>>
>> This would still allow most interesting cases that involve recursion
>> between shapes, but excludes cases where the same instances are
>> visited more than once.
>>
>> What am I missing?
>>
>> Thanks,
>> Holger

Received on Thursday, 11 June 2015 20:26:46 UTC