An auditor reviews Alice’s claim that Bob knows Carol. In RDF 1.2 that is a triple term inside a triple term. EyeProlog matches the whole nesting with one pattern and recovers the innermost relationship.
Run it in the playground · Source
Which relationship sits at the bottom of a review of a claim?
This is one of a family of RDF 1.2 examples. RDF data arrives as
rdf(Subject, Predicate, Object, Graph) facts, as produced by
rdf-prolog-interchange,
and results are printed in the same shape.
rdf(iri('https://example.org/auditor'), iri('https://example.org/reviews'), triple(iri('https://example.org/alice'), iri('https://example.org/claims'), triple(iri('https://example.org/bob'), iri('https://example.org/knows'), iri('https://example.org/carol'))), default_graph).
Triple terms nest: the auditor reviews a statement whose object is itself a statement. Each level is a statement about the one below it, and none of them is asserted as plain fact.
result_rdf(S, iri('https://example.org/knows'), O, G) :-
rdf(
_,
iri('https://example.org/reviews'),
triple(
_,
iri('https://example.org/claims'),
triple(S, iri('https://example.org/knows'), O)
),
G
).
The pattern has the same shape as the data. Nesting needs no special query language: a nested term is matched by a nested pattern.
eyeprolog examples/rdf12-nested-triple-term.pl
result_rdf(iri('https://example.org/bob'), iri('https://example.org/knows'), iri('https://example.org/carol'), default_graph).
step(result_rdf(iri('https://example.org/bob'), iri('https://example.org/knows'), iri('https://example.org/carol'), default_graph),
rule(2),
['S' = iri('https://example.org/bob'),
'O' = iri('https://example.org/carol'),
'G' = default_graph],
[rdf(iri('https://example.org/auditor'), iri('https://example.org/reviews'), triple(iri('https://example.org/alice'), iri('https://example.org/claims'), triple(iri('https://example.org/bob'), iri('https://example.org/knows'), iri('https://example.org/carol'))), default_graph)]).
The proof cites the single reviewed triple. Who reviewed, who claimed, and what was claimed all stay visible in that one premise.
condition('C1', resolution, ok, 2).
condition('C4', coverage, ok, 2).
condition('C7', relevance, ok, 3).
trusted(0).
verdict(checked).
Learn more in The Art of EyeProlog, Chapter 9.