0

I have an ontology in which each thematic role (e.g., has-agent) is represented via an object property. Furthermore, the inverse property is always defined (e.g., is-agent-of).

I want to assert in the ontology all inverse triples via SHACL rules PROVIDED THAT THEY DO NOT ALREADY EXIST.

Thus, I wrote the following rule:

:assertInverseTriplesOnHasAgent rdf:type sh:NodeShape;
    sh:rule [rdf:type sh:TripleRule;
        sh:condition
        [
            sh:not[
                sh:property[
                    sh:path (TBox:has-agent TBox:is-agent-of);
                    sh:minCount 1;
                    sh:equals sh:this
                ]
            ]
        ];
        sh:subject [sh:path TBox:has-agent];
        sh:predicate TBox:is-agent-of;
        sh:object sh:this
    ];
    sh:targetSubjectsOf TBox:has-agent.

But it does not work: it asserts the inverse triples even when they already exist (and it shouldn't).

I suspect that "sh:equals sh:this" is not correct, i.e., that "sh:this" cannot be used within sh:property. On the other hand, "sh:minCount 1;" alone does not work because someone can be is-agent-of more than one action.

Can anyone help me? Thanks

  • 2
    What would be the harm of inferring a triple that already exists? RDF graphs are sets of triples, and duplicate should not matter. Also note that the values of sh:equals need to be properties, so you may mean sh:hasValue (which in this case also would not work because you cannot put node expressions such as sh:this there. – Holger Knublauch Aug 08 '21 at 22:44
  • Thanks Holger! You are right, there is no harm to assert the same triples multiple times, from a logical point of view. My question concerned more the computational efficiency point of view. Maybe I'm too perfectionist :-) Never mind, I can always choose to implement the inferences in Java so I can control every single step (e.g., check that a triple I want to assert does not already exist). – Livio Robaldo Aug 12 '21 at 10:32
  • On the other hand, your comment on sh:equals/sh:hasValue/sh:this made me thinking that I actually did not understand how they work :-( I studied again and I have a new question that I put in this new post: https://stackoverflow.com/questions/68755557/how-to-compare-individuals-through-two-paths-in-shacl. Thanks again for all your help! :-) – Livio Robaldo Aug 12 '21 at 10:32

0 Answers0