Selecting an adult with an English name

A name carries its language with it; one rule reads that tag and an age.

base-and-literals.n3 · output · proof · check · try it in the playground


The question

In RDF a piece of text can say which language it is in: "Alice Smith"@en is English, "Bob"@nl is Dutch. Numbers such as 22 are values of their own, not text.

We know two people, each with a name and an age.

Who is an adult (18 or older) with a name tagged as English?


What we tell Eyeron

:alice :name "Alice Smith"@en ;
    :age 22 .
:bob :name "Bob"@nl ;
    :age 17 .

The ; continues with the same subject, so Alice has both a name and an age.

{
    ?person :name ?name .
    ?person :age ?age .
    ?pair log:langlit ?name .
    ?pair list:firstRest (?value ?rest) .
    ?rest list:firstRest (?lang ?rest2) .
    ?lang log:equalTo "en" .
    ?age math:notLessThan 18
} => {
    ?person :adult true
} .

The rule uses built-ins: predicates that Eyeron computes instead of looking up.


What Eyeron concludes

:alice :adult true .

Alice qualifies. Bob fails on both counts: his name is Dutch and he is 17. The rule needs both conditions, so fixing only one of them is not enough.


The proof, step by step

The proof records the one rule step with every variable’s value, and the seven statements it uses:

{ :alice :adult true . }
  pe:rule 1;
  pe:binding
    [ pe:var "age"; pe:value 22 ],
    [ pe:var "lang"; pe:value "en" ],
    [ pe:var "name"; pe:value "Alice Smith"@en ],
    [ pe:var "pair"; pe:value ("Alice Smith" "en") ],
    …
  pe:uses
    { :alice :name "Alice Smith"@en . },
    { :alice :age 22 . },
    { ("Alice Smith" "en") log:langlit "Alice Smith"@en . },
    …
    { 22 math:notLessThan 18 . }.

Two of them are facts from the file:

{ :alice :age 22 . }
  pe:fact "base-and-literals.n3".

The other five are built-in results, each marked as such:

{ ("Alice Smith" "en") log:langlit "Alice Smith"@en . }
  pe:builtin log:langlit.

Checked: what the report says

# checked: 8 steps, 8 verified, 0 trusted
pe:verdict pe:checked;
pe:condition [ pe:id "C1"; pe:name "resolution"; pe:checked 3; pe:failed 0 ];
pe:condition [ pe:id "C5"; pe:name "re-decision"; pe:checked 5; pe:failed 0 ];
pe:condition [ pe:id "C10"; pe:name "call fidelity"; pe:checked 1; pe:failed 0 ].

All 8 steps were verified, none taken on trust: the verdict is checked. It confirms Alice; it does not by itself show that Bob is excluded.


Try it

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

Change Bob’s name to "Bob"@en and his age to 19: he becomes an adult too. Change only one of the two and he stays out.


Takeaway

Language tags are part of a literal’s value, and built-ins let a rule read them as easily as a number; the checker recomputes every such reading.