Alice claims that Bob knows Carol. RDF 1.2 can record that claim as a triple term: a triple used as a value inside another triple. EyeProlog reads it as an ordinary nested Prolog term and lifts the quoted relationship out into a result of its own.
Run it in the playground · Source
What relationship is inside Alice’s 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;
ordinary rules derive new results in the same shape, and write_results/0
prints them as rdf/4 facts that convert straight back to RDF.
rdf(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).
A triple term is a whole statement used as the object of another
statement. Here the object of claims is triple(bob, knows, carol). The
data does not say that Bob knows Carol; it says that Alice claims so.
result_rdf(S, iri('https://example.org/knows'), O, G) :-
rdf(
_,
iri('https://example.org/claims'),
triple(S, iri('https://example.org/knows'), O),
G
).
Unification looks inside the triple term: the pattern
triple(S, knows, O) matches the quoted statement and binds its subject and
object. Projecting a claim into a plain relationship is a decision this rule
makes explicitly; nothing in RDF does it for you.
eyeprolog examples/rdf12-triple-term.pl
result_rdf(iri('https://example.org/bob'), iri('https://example.org/knows'), iri('https://example.org/carol'), default_graph).
One relationship, recovered from inside the claim.
eyeprolog --proof examples/rdf12-triple-term.pl
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/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 result rests on exactly one source triple: Alice’s claim. An auditor can see that the asserted relationship came from a claim, and whose claim it was.
condition('C1', resolution, ok, 2).
condition('C4', coverage, ok, 2).
condition('C7', relevance, ok, 3).
trusted(0).
verdict(checked).
Both steps replay against the program and nothing is taken on trust.
knows to likes inside the triple term. The run prints nothing:
the rule only projects knows claims.Learn more in The Art of EyeProlog, Chapter 9.