Skip to content

Inverse Property Value Rules #181

Open
@tpluscode

Description

@tpluscode

At the moment SHACL-AF only defines the shorthand syntax and behaviour of Property Value Rules when the path is an IRI

I think it should also be allowed to have property rules set on properties whose property is sh:InversePath. That can be trivially achieved by switching places of sh:object and sh:subject of the implicit triple rule:

8.5.2 Inverse Property Value Rules

Similar to [Property Value Rule](#8.5.2) but with `sh:object` and `sh:subject` reversed, 
that is for the implicit rule `T`:

- T sh:subject V
- T sh:object sh:this

Activity

HolgerKnublauch

HolgerKnublauch commented on Mar 8, 2023

@HolgerKnublauch
Contributor

Sounds plausible.

tpluscode

tpluscode commented on Oct 15, 2023

@tpluscode
ContributorAuthor

Would you accept PR, actually?

HolgerKnublauch

HolgerKnublauch commented on Oct 16, 2023

@HolgerKnublauch
Contributor

Have you implemented this and encountered problems? I do remember that I thought about this but didn't go there because that inverse case caused complications. I guess it is because they may produce "cycles" where inferring one "forward" value may later also infer an "inverse" value. Or, at the minimum, I didn't see enough value to include that feature, although from a symmetry point of view it would make sense.

What is your specific use case?

tpluscode

tpluscode commented on Oct 16, 2023

@tpluscode
ContributorAuthor

I don't remember exact details now but I found this missing when implementing a SPARQL Query generator

HolgerKnublauch

HolgerKnublauch commented on Oct 16, 2023

@HolgerKnublauch
Contributor

In my implementation of sh:path node expressions, the system will automatically "infer" properties that have a sh:values rule. If we were to add this for the inverse direction, it would at least complicate these cases. Unless there is a strong use case and evidence that this has a reasonable cost-benefits ratio, I would rather table this for a future WG.

tpluscode

tpluscode commented on Oct 16, 2023

@tpluscode
ContributorAuthor

I would rather table this for a future WG.

Fair enough

transferred this issue fromw3c/shaclon Jan 20, 2025
HolgerKnublauch

HolgerKnublauch commented on Feb 23, 2025

@HolgerKnublauch
Contributor

With Node Expressions directly used at sh:path, I believe this ticket can be closed, @tpluscode?

tpluscode

tpluscode commented on Feb 23, 2025

@tpluscode
ContributorAuthor

Can you point to an example of what you have in mind?

HolgerKnublauch

HolgerKnublauch commented on Feb 23, 2025

@HolgerKnublauch
Contributor

https://github.com/w3c/data-shapes/blob/issue-222-node-expressions/shacl12-core/index.html#L1640

What you are originally asking here assumes that there is a separate property that will be inferred (because sh:values was separate from the sh:path). Above these two are linked.

The SHACL inference rules spec may introduce a new property sh:alias or sh:inferredProperty that would materialize the derived properties. Maybe that could be inverse too and your ticket remains valid?

tpluscode

tpluscode commented on Mar 2, 2025

@tpluscode
ContributorAuthor

Hm, are we talking about the same? Here's an example of a valid Property Shape (as per SHACL-AF).

[]
  sh:path ex:foo ;
  sh:values ex:bar ;
.

Using a constant node expression, this translates to an inferred triples which looks like $this ex:foo ex:bar.

What I found missing, was to allow sh:path [ sh:inversePath ex:foo ] in a Property Value Rule to produce triples like ex:bar ex:foo $this

added this to the Phase 2 milestone on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    InferencingFor SHACL 1.2 Inferencing spec.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Inverse Property Value Rules · Issue #181 · w3c/data-shapes