Search code examples
rdfowlsesamerdfs

In Sesame, how does one derive RDFS/OWL materialization results that have an RDF literal in the subject position?


I have a problem with RDFS entailment in Sesame 2.8.5. I want to automatically deduce (3) from (1) and (2) (using Turtle notation here). This is defined as rule rdfs3 in the RDF 1.1 specification and as rule prp-rng in the OWL-RL specification.

(1) foaf:givenName rdfs:range     xsd:string .
(2) ex:wouter      foaf:givenName "Wouter"   .
(3) "Wouter"       a              xsd:string .

I have implemented this in Sesame using the ForwardChainingRDFSInferencer class as follows:

public static void main(String[] args) throws RepositoryException, RDFHandlerException {
  Repository r = new SailRepository(new ForwardChainingRDFSInferencer(new MemoryStore()));
  r.initialize();
  ValueFactory f = r.getValueFactory();
  RepositoryConnection c = r.getConnection();
  try {
    c.add(FOAF.GIVEN_NAME, RDFS.RANGE, XMLSchema.STRING);
    c.add(f.createURI("http://example.org/", "wouter"), FOAF.GIVEN_NAME, f.createLiteral("Wouter", XMLSchema.STRING));
    RepositoryResult<Statement> s = c.getStatements(null, null, null, true);
    Rio.write(Iterations.addAll(s, new LinkedHashModel()), System.out, RDFFormat.TURTLE);
  } finally {c.close();}
}

The output contains many inferred facts such as (4) but does not include fact (3).

(4) ex:wouter a rdfs:Resource .

My question is: If fact 3 is not derived because a literal is not allowed to appear in the subject position of an RDF triple, then how it it possible to perform full RDFS and/or OWL materialization (in line with the above mentioned specifications) in Sesame?


Solution

  • Literals are not allowed in subject positions in RDF. Therefore, fact 3 would not be a legal RDF triple, and therefore Sesame's inferencer does not derive it. This does not mean that Sesame's inferencer is incomplete: it derives all RDFS-entailed facts that can be legally derived. Or if you wish to argue that this does constitute incompleteness, then that means that any RDF reasoner implementing RDFS Entailment is by definition incomplete, as it will not be able to derive such facts within the RDF standard.

    Note that the RDF Semantics spec explicitly refers to a notion of "generalized RDF" when discussing the possibility of having literals in subject positions (and making the type of entailments you want) - however this notion is itself a hypothetical extension of the standard, and not itself normative.

    So, long story short: if you want literals in subject positions, you are not doing RDF, and you can't use Sesame (or any other standards-compliant RDF framework).