Similar

Two things are similar when something true of one is true of the other.

similar.n3 · output · proof · check · try it in the playground


The question

Alice is a human, and so is Bob. Call two things similar when they share a property: the same relation to the same thing.

Are Alice and Bob similar?


What we tell Eyeron

:Alice a :Human .
:Bob a :Human .

A forward rule states the test: if Alice is similar to Bob, the test passed.

{
    :Alice :similar :Bob .
} => {
    :test :is true .
} .

Nothing says directly that anyone is similar. That is defined by a backward rule, written with <=: to show the head, show the body.

{
    ?A :similar ?B .
} <= {
    ?A ?Pred ?Obj .
    ?B ?Pred ?Obj .
} .

The predicate here is a variable, ?Pred, so the rule does not care which property is shared: being a human, living in the same city, anything.


What Eyeron concludes

:test :is true .

:Alice :similar :Bob itself is not printed. A backward rule is only used when something asks for it, here the forward rule’s premise; its answer serves that question and is not added to the output.


The proof, step by step

{ :test :is true . }
  pe:rule 1;
  pe:uses { :Alice :similar :Bob . }.

{ :Alice :similar :Bob . }
  pe:rule 2;
  pe:binding
    [ pe:var "A"; pe:value :Alice ],
    [ pe:var "B"; pe:value :Bob ],
    [ pe:var "Obj"; pe:value :Human ],
    [ pe:var "Pred"; pe:value rdf:type ];
  1. The test passed, by rule 1, because Alice is similar to Bob.
  2. Alice is similar to Bob, by rule 2, the backward rule, with Pred standing for rdf:type (what a abbreviates) and Obj for :Human.
  3. and 4. The two facts given in similar.n3.

Checked: what the report says

# checked: 4 steps, 4 verified, 0 trusted
pe:condition [ pe:id "C1"; pe:name "resolution"; pe:checked 4; pe:failed 0 ];
pe:condition [ pe:id "C10"; pe:name "call fidelity"; pe:checked 2; pe:failed 0 ].

Nothing is computed, negated or invented, so the other conditions examined nothing. All 4 steps are verified: the verdict is checked.


Try it

eyeron examples/similar.n3      # the answer
eyeron -p examples/similar.n3   # the answer with its proof
eyeron -c examples/similar.n3   # the proof, checked

Change :Bob a :Human . into :Bob a :Robot .: Alice and Bob no longer share anything, and Eyeron concludes nothing. Then add :Alice :livesIn :Ghent . and :Bob :livesIn :Ghent .: they are similar again, through a different property.


Takeaway

A backward rule with a variable predicate defines “similar” once for every kind of property, and the proof says exactly which shared property was used.