N3 delivery witnesses

One stable Skolem IRI per order, shared by the delivery link and ready status.

N3 source · output · proof · check · playground


The question

Two paid orders each need a delivery record. How can both triples about one record use the same name, while different orders get different records?


Historical background

RDF 1.1 recorded the practice of replacing blank nodes with fresh IRIs when applications need stable references. Here a delivery witness gets an identifier computed for its paid order, so later statements can describe the delivery itself. RDF 1.1 Concepts, replacing blank nodes with IRIs


What the N3 says

@prefix : <https://example.org/delivery#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .

:order1 :status :paid .
:order2 :status :paid .

{
  ?order :status :paid .
  (:delivery ?order) log:skolem ?delivery
} => {
  ?order :delivery ?delivery .
  ?delivery :status :ready .
} .

(:delivery ?order) is the naming key. log:skolem computes an IRI from its canonical term text using SHA-256. Both conclusion triples use that computed value. Repeating the same key produces the same IRI; adding another order leaves the first two names unchanged. The role :delivery is part of the key so another kind of record can use a different key for the same order.

The variable ?delivery is bound in the premise. The compiler therefore produces an ordinary forward rule, with no conclusion-only existential variable. This example deliberately assigns a deterministic name to every paid order’s delivery; it does not test whether a different delivery was already supplied.


What eyemind concludes

There are four conclusions: a delivery link and a ready-status triple for each order. Each pair shares one IRI, and the two orders use different IRIs.

The check report writes the claims as terms:

// Checked answers: these follow from the input program and are every answer of its questions.
rdf(iri('https://example.org/delivery#order1'), iri('https://example.org/delivery#delivery'), iri('https://eyereasoner.github.io/.well-known/genid/3213a0e029482d0ca0c2d0d6677d39ca7acaacb155b42de122a869757d2ef2a6'))
rdf(iri('https://eyereasoner.github.io/.well-known/genid/3213a0e029482d0ca0c2d0d6677d39ca7acaacb155b42de122a869757d2ef2a6'), iri('https://example.org/delivery#status'), iri('https://example.org/delivery#ready'))
rdf(iri('https://example.org/delivery#order2'), iri('https://example.org/delivery#delivery'), iri('https://eyereasoner.github.io/.well-known/genid/5db2153099ad05a8d82608bdfa7738f98bd3a827616c8bec408caff1259c0c71'))
rdf(iri('https://eyereasoner.github.io/.well-known/genid/5db2153099ad05a8d82608bdfa7738f98bd3a827616c8bec408caff1259c0c71'), iri('https://example.org/delivery#status'), iri('https://example.org/delivery#ready'))

What the proof establishes

Replaying each firing computes the term text, SHA-256 hash and IRI construction again. Changing a generated IRI consistently throughout a forged proof still fails those computations. The name is computed in the premise, so the rule has no witness of its own.

The verdict is checked: the claims follow from the compiled program and are every answer of its original questions. The saved proof can be compared with --program output, whose clause numbers its steps cite.


Try it

node bin/eyemind.js examples/witnesses-n3.n3
node bin/eyemind.js -c examples/witnesses-n3.n3
node bin/eyemind.js --check-proof examples/proof/witnesses-n3.js examples/witnesses-n3.n3

Add :order3 :status :paid . to a copy. It receives a third delivery IRI, while the names of the first two deliveries stay the same.