Skip to content

Instantly share code, notes, and snippets.

@justin2004
Last active September 20, 2022 12:18
Show Gist options
  • Select an option

  • Save justin2004/81951184f3dcb496e80eecdf09774b91 to your computer and use it in GitHub Desktop.

Select an option

Save justin2004/81951184f3dcb496e80eecdf09774b91 to your computer and use it in GitHub Desktop.
RDFox reasoning vs Apache Jena reasoning

Apache Jena's OWL reasoner imports tbox.ttl and abox.ttl then derives jena_output_subset.ttl as expected.

RDFox won't import tbox.ttl and produce derivations. But it looks like OWL 2 RL recognizes:

  • intersection of class expressions (ObjectIntersectionOf)
  • existential quantification to a class expression (ObjectSomeValuesFrom)
  • existential quantification to an individual (ObjectHasValue)

Which are used in tbox.ttl. From the docs it looks like RDFox supports OWL 2 RL.

@prefix : <http://example.com/> .
@prefix gist: <https://ontologies.semanticarts.com/gist/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
:Case11 :hasParticipant :Fred .
:Fred :followsDirectionOf :Bob .
:Sally rdf:type :CourtXJustice .
:Bob rdf:type :CourtXJustice .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://example.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix gist: <https://ontologies.semanticarts.com/gist/> .
:Fred gist:isMemberOf :Case11Jury .
> importaxioms :tbox
Named graph :tbox will be parsed for OWL axioms (without assertions), and the result will be added to named graph rdfox:DefaultTriples.
Warning: http://www.oxfordsemantic.tech/f1demo/tbox: The following triples could not be translated to OWL axioms:
_:__import40__anonymous1 rdf:type owl:Class .
_:__import40__anonymous2 rdf:type owl:Restriction .
_:__import40__anonymous6 rdf:type owl:Restriction .
_:__import40__anonymous7 rdf:rest rdf:nil .
_:__import40__anonymous1 owl:intersectionOf _:__import40__anonymous5 .
_:__import40__anonymous2 owl:hasValue <http://example.com/Case11Jury> .
_:__import40__anonymous6 owl:someValuesFrom <http://example.com/CourtXJustice> .
_:__import40__anonymous2 owl:onProperty <https://ontologies.semanticarts.com/gist/isMemberOf> .
_:__import40__anonymous6 owl:onProperty <http://example.com/followsDirectionOf> .
_:__import40__anonymous5 rdf:first _:__import40__anonymous3 .
_:__import40__anonymous7 rdf:first _:__import40__anonymous6 .
_:__import40__anonymous5 rdf:rest _:__import40__anonymous7 .
_:__import40__anonymous1 rdfs:subClassOf _:__import40__anonymous2 .
Import operation took 0.001 s.
1 warning was encountered during import.
@prefix : <http://example.com/> .
@prefix gist: <https://ontologies.semanticarts.com/gist/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[ rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:hasValue :Case11Jury ;
owl:onProperty gist:isMemberOf
] ;
owl:intersectionOf ( [ rdf:type owl:Restriction ;
owl:hasValue :Case11 ;
owl:onProperty [ owl:inverseOf :hasParticipant ]
]
[ rdf:type owl:Restriction ;
owl:onProperty :followsDirectionOf ;
owl:someValuesFrom :CourtXJustice
]
)
] .

ghost commented Sep 20, 2022

Copy link
Copy Markdown

The issue is that the ontology is incomplete. You will need to declare the OWL properties and classes, by adding these triples to the tbox:
gist:isMemberOf a owl:ObjectProperty . :hasParticipant a owl:ObjectProperty . :followsDirectionOf a owl:ObjectProperty . :CourtXJustice a owl:Class .

The issue of course is that the ontology would be invalid if some of these were declared as, say, owl:DatatypeProperty.

I have checked that adding these 4 lines is enough for RDFox to be happy.

@justin2004

Copy link
Copy Markdown
Author

Thanks, @vcocchi-ost ! It worked for me as well.

I replied to the tweet as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment