The current implementation of Thea makes use of the SWI-Prolog semweb package as means of parsing OWL encoded as RDF/XML, according to the Mapping to RDF Graphs specification. After the triples have been translated into owl2_model facts such as EquivalentClasses/1, they are discarded. This is somewhat analagous to how the java OWLAPI views RDF – merely as an exchange format.
This means it is possible to use Thea to convert an OWL ontology encoded in RDF to native prolog facts such as:
(real URIs have been replaced by names in the above)
And then use another prolog system that lacks the rich RDF libraries of SWI to process the ontology.
This also has lots of advantages when working in a purely OWL world, but has some disadvantages when working with mixed RDF and OWL views. From an engineering perspective it would be nice to be able to take more advantage of the useful features of the SWI semweb library (in particular, namespace support). Ideally the programmer could choose whether the OWL predicates were served from an RDF store or from native prolog facts.
This is now possible, to a certain extent, using the newrdf branch in github. Note that the posh and pkb branches frequently merge in from this branch.
This branch includes a module owl2_rdf that serves owl2_model predicates directly from semweb/rdf_db.pl in SWI. Check the comments in the code for how DCGs are used for a very compact declarative coding of the mapping.
The idea is to allow seamless switching between backing stores. To use the direct RDF store, specify “rdf_direct” as the format. In prolog:
On the command line:
thea --format rdf_direct foo.owl --query select A where "axiom(A)"
For most purposes, there should be no noticeable differemce. However, if you now wish to mix and match RDF, SPARQL and OWL in prolog the picture is much better. E.g. try the following:
thea-poshj --format rdf_direct ceph.owl
?- rdf_has(X, rdfs:subClassOf, Y).
The direct rdf query returns the same axioms (with the difference that the rdf query Y may bind to bNodes, whereas with subClassOf/2, Y binds to prolog terms corresponding to class expressions.
In fact, from within Posh, you can now type the command “clio.” to launch a ClioPatria semantic web server complete with custom OWL views.
There are still a few quirks that need ironed out before newrdf is merged into master
- Efficiency is a challenge. When mapping a query such as subClassOf/2 to rdf_has/3, additional calls have to be made to map bNodes to prolog terms. This has to be done in the correct order for efficiency. This has now been done for a few predicates, but others are noticeably slow on ontologies such as snomed
- This is particularly challenging for OWL axioms that takes sets as arguments (e.g. equivalentClasses/1) and have to be mapped to pairwise RDF calls
- assert_axiom/2 needs to be mapped
However, for many purposes the current behavior should be fine.