A few general statements about categories and relations, and the facts that follow from them.
schema-inference.pl · output · proof · check · try it in the playground
Data on the web often comes with a schema: general statements about what the data means. “Every cat is a mammal.” “If someone is a parent of someone, they are related.” “Only people can be parents.”
Given a schema and a couple of plain facts — Koko is a cat; Alice is Bob’s parent —
what else can we safely conclude? And can each conclusion be traced back to the statements it came from?
parent_of
implies related_to.parent_of is a person.These are the core ideas of the web’s RDF Schema, written here as ordinary rules.
subclass(cat, mammal).
subclass(mammal, animal).
subproperty(parent_of, related_to).
domain(parent_of, person).
range(parent_of, person).
type(koko, cat).
triple(alice, parent_of, bob).
subclass(A, C) :+ subclass(A, B), subclass(B, C).
type(X, B) :+ type(X, A), subclass(A, B).
triple(S, Q, O) :+ triple(S, P, O), subproperty(P, Q).
type(S, Class) :+ triple(S, P, _), domain(P, Class).
type(O, Class) :+ triple(_, P, O), range(P, Class).
:+ means “keep applying this until nothing new follows”. No question is
asked, so Eyedia reports everything new.
subclass(cat, animal).
type(koko, animal).
type(koko, mammal).
triple(alice, related_to, bob).
type(alice, person).
type(bob, person).
Six new facts, none of them typed in:
Each conclusion cites the rule and facts behind it:
parent_of implies related_to, so Alice
is related to Bob — rule 10.Step 2 builds on step 1: one conclusion feeds the next.
A separate checker read all 13 proof steps against the program and confirmed that:
Verdict: checked. Nothing taken on trust.
node bin/eyedia.js examples/schema-inference.pl # the new facts
node bin/eyedia.js --proof examples/schema-inference.pl # with their proof
Or open it in the playground.
Add triple(bob, parent_of, carol). and run again: Bob becomes related to
Carol, and Carol is concluded to be a person.
A schema says a lot in a few lines. Eyedia spells out what it implies, and every implied fact comes with the exact statements that support it — so a surprising conclusion can be traced to the schema line that caused it.