Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property Shapes without paths #77

Open
tpluscode opened this issue Aug 22, 2024 · 7 comments
Open

Property Shapes without paths #77

tpluscode opened this issue Aug 22, 2024 · 7 comments

Comments

@tpluscode
Copy link

Pleas consider this shape, as mentioned in issue zazuko/rdf-validate-shacl#140

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix ex: <http://example.com/> .

ex:PersonAddressShape
    a sh:NodeShape ;
    sh:targetClass schema:Person ;
    sh:property ex:age .

ex:minCount    a sh:PropertyShape ;
        sh:minCount 1 .

ex:age    a sh:PropertyShape ;
        sh:path schema:age ;
        sh:and ( ex:minCount ) .

It seems logical to be able to reuse parts of property shapes like this but this is invalid SHACL, because ex:minCount does not have a sh:path

On the other hand TopBraid's SHACL implementation does support this construct as one would expect.

Should the definition of property shape be relaxed?

@VladimirAlexiev
Copy link
Contributor

@tpluscode and @matthiaspalmer (who was poster of the original issue)

  • Isn't and supposed to have at least 2 arguments?
  • Seems to me you are using and as a marker to say "... and now incorporate all features of the following, by reference"?
  • So it's not just about "relax the definition of property shape" but also about imparting some completely new semantics?
  • And what would be the semantics if the piece you want to reuse defines its own sh:path?
ex:minCount    a sh:PropertyShape ;
  sh:path ex:foo;
  sh:minCount 1 

@matthiaspalmer
Copy link

@VladimirAlexiev my toughts per point below.

@tpluscode and @matthiaspalmer (who was poster of the original issue)

  • Isn't and supposed to have at least 2 arguments?

Don't think so, the range of sh:and is a SHACL List, there is nothing in section 4.6.2 that says it must have 2 arguments.

  • Seems to me you are using and as a marker to say "... and now incorporate all features of the following, by reference"?

Yes, exactly, this is what I would like to achieve. i.e. a way of using and would allow you to "extend" property Shapes.

  • So it's not just about "relax the definition of property shape" but also about imparting some completely new semantics?

I do not see that this is new semantics, I think this is how sh:and should work. Or am I missing something?

  • And what would be the semantics if the piece you want to reuse defines its own sh:path?
ex:minCount    a sh:PropertyShape ;
  sh:path ex:foo;
  sh:minCount 1 

That would a shape expression that is not possible to satisfy, unless ex:foo is a subproperty of ex:age and you validate with entailment enabled.

But "impossible shapes" is not unique to this situation. Just consider a shape with minCount 2 and maxCount 1.

@tpluscode
Copy link
Author

Thanks @matthiaspalmer, I never got a reply I was satisfied with but I like your argument about "impossible shapes". You can achieve unsatisfiable shapes in various ways.

Seems to me you are using and as a marker to say "... and now incorporate all features of the following, by reference"?

I'd say that is exactly what and is meant for. Maybe more often used in Node Shapes.

Isn't and supposed to have at least 2 arguments?

The >2 element rule applies to sequence paths. Maybe that's what you thought of @VladimirAlexiev

And what would be the semantics if the piece you want to reuse defines its own sh:path?

Alternatively to what @matthiaspalmer said, the path could be ignored and the constraints incorporated into the parent Property Shape? 🤔

@VladimirAlexiev
Copy link
Contributor

  • @tpluscode and @matthiaspalmer I never thought of Unary conjunction. I guess it's needed for logical completeness (even zeroary conjunction, its value is True).
  • But how about this requirement "Each member of such list must be a well-formed shape". A PropertyShape without path is not well formed. You want to reuse not property shapes, but only aspects of them
  • "I'd say that is exactly what and is meant for. Maybe more often used in Node Shapes": the key difference is that the conjuncts are self-contained shapes, whereas here you propose conjuncts that are partial shapes
  • @matthiaspalmer the "new semantics" consists in the need to define how partial shapes are combined and only then evaluated. The spec says "conformance checking of v against any of the members of $and", it doesn't say "members of $and combined in some new way with aspects of the invoking shape".

If you want to reuse aspects of property shapes, I think the right way is to look into Constraint Components?

@tpluscode
Copy link
Author

@HolgerKnublauch, could you comment on this scenario being seeming supported by the TB implementation?

@HolgerKnublauch
Copy link
Contributor

The spec states that the behaviour of SHACL engines against malformed shapes graphs is undefined. So if my code does allow these incomplete property shapes without sh:path through then this is officially allowed.

For SHACL 1.2 we could strengthen those cases though and say that a sh:PropertyShape without a sh:path should throw a failure and stop validation.

@tpluscode tpluscode changed the title Property Shapes with paths Property Shapes without paths Sep 17, 2024
@VladimirAlexiev
Copy link
Contributor

A PropertyShape without path is not well formed.

Here's the evidence: https://www.w3.org/TR/shacl/#property-shapes

A property shape is a shape in the shapes graph that is the subject of a triple that has sh:path as its predicate.
sh:PropertyShape have one value for the property sh:path.

Property Shapes without sh:path will not even be recognized as such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants