Re: A question regarding the semantics of multi-triple term reifications and querying

Hi Olaf,

thank you for your help!

> On 11. Sep 2025, at 17:51, Olaf Hartig <olaf.hartig@liu.se> wrote:
> 
> Hi Thomas,
> 
> On Thu, 2025-09-11 at 17:16 +0200, Thomas Lörtsch wrote:
>> Since reifiers can refer to multiple triple terms, do queries for annotations on a triple need to filter out eventual
>> multi-triple term annotations? Take for example the following graph.:
>> 
>>    :r rdf:reifies <<( :s :p :o )>> ,
>>                   <<( :x :y :z )>> ;
>>        :b :c .
>> 
>> Querying for all annotations on <<( :s :p :o )>> might naively query for all annotations on reifiers that rdf:reify
>> <<( :s :p :o )>>, e.g.:
>> 
>> 
>>    select ?pred ?obj where {
>>      _:x rdf:reifies <<( :s :p :o )>> ;
>>          ?pred ?obj
>>    }
>> 
>> However, in the above example that would return the annotation ':r :a :b',
> 
> Assuming you meant ':r :b :c', then yes, one of the solution mappings in the result of this query over the graph given
> above, is { ?pred -> :b, ?obj -> :c }.
> 
> In addition to this one, there are two more solution mappings in the result:
> { ?pred -> rdf:reifies, ?obj -> <<( :s :p :o )>> } 
> and
> { ?pred -> rdf:reifies, ?obj -> <<( :x :y :z )>> }

Right.

> That's exactly what the query asks for. If you want to retrieve data about a reifier that reifies only <<( :s :p :o )>>
> and nothing else---at least not within the graph that you are querying---then you need to specify that as an additional
> condition in your query.

IIUC specifying that additional condition requires something like 

    FILTER NOT EXISTS { 
        ?reifier rdf:reifies ?otherTriple . 
        FILTER (?otherTriple != <<( :s :p :o )>> ) 
    }


> Notice also that this is not specific to reifiers at all! As an example, consider the graph
> 
> :s :p 1 .
> :s :p 2 .
> :s :q :y .
> 
> and the query
> 
> SELECT ?v WHERE {
>   _:b :p 1 .
>   _:b :q ?v
> }
> 
> Also here, you get a solution mapping { ?v -> :y }.

Indeed! That seems to suggest that in a multi-part reifier the combination of individual triple terms is to be understood as OR, not AND, and that my intuition was wrong. I agree that this should not be surprising, given the general design of RDF.

I think this topic should be part of introductory material.


Thanks again,
Thomas


> -Olaf
> 
> 
>> but ':r' doesn’t just reify <<( :s :p :o )>>, it reifies <<( :s :p :o )>> AND <<( :x :y :z )>>. I at least consider
>> that a difference (but I’m not quite sure if the specs do too).
>> 
>> OTOH, filtering out multi-triple term reifiers like ':r' from a result set is pretty tedious, especially if it would
>> have to be done on a regular basis.
>> 
>> Best,
>> Thomas
> 

Received on Monday, 15 September 2025 08:30:54 UTC