Lightweight subPropertyOf / subClassOf inference with ARC2

As a regular user of the ARC2 framework, I really enjoy the way it ease the development of Semantic-Web applications. Especially, its SPARQL capabilities offer an intuitive way to write / get / update graphs and triples in the backend triple-store.

Unfortunately, while ARC2 provides resource consolidation based on IFPs or using some pre-defined properties, it does not feature lightweight RDFS entailement based on subPropertyOf and subClassOf subsumption. As Benjamin pointed out on IRC, such inference can be done using a combination of ARC2 triggers and SPARQL INSERT / CONSTRUCT clause. I just created two triggers that does the job, providing lightweight inferencing for subproperties and subclasses in ARC2, using the SPARQL query that follows (in that case, regarding the properties):

 ?s ?top ?o .
  GRAPH <$graph> {
    ?s ?prop ?o .
  ?prop rdfs:subPropertyOf ?top .

The trigger are, in my case, launched after each LOAD action, but can also be used in combinaison with the INSERT clause, by simply editing the store parameters:

$config = $arc_config + array
  'store_triggers' => array(
    'insert' => array('graphTimestamp'),
    'load' => array('subPropertyInference'),

As you can notice, the query is limited to a particular $graph (both in selecting and inserting). As this $graph var corresponds to the URI of the graph that has just been loaded in the store, it avoids recomputing the triples on the whole store each time a new graph is added. Moreover the new statements also belong to the original graph. You might want to change this according to your inference policy, but I think for such lightweight inference patterns (that do not involve other graphs), that makes sense to store additional statements in the original graph.

Regarding the inference pattern itself, instead of defining manually the properties that must be taken into account, this query retrieves all the properties that have been defined as subproperties of any others to automatically infer the ‘top property’ relationship. While this is certainly better than manually adding some property / subproperty lists, especially for maintenance purposes, it requires that the underlying models (e.g. FOAF if you want to deal with rdfs:label / foaf:name subsumption) must be loaded in the triple store, which you can do when setting it up, e.g.:

$default_vocabs = array(
// Setup the store
// Load ontologies so that we can infer subproperties later
foreach($default_vocabs as $vocab) {
  $graph = LODrTools::get_datagraph($vocab);
  $this->store->query("LOAD <$vocab> INTO <$graph>");

Then, you can benefit from that lightweight inference engine when querying data from your store, as for instance a query related to “?s rdfs:label ?o” will retrieve “?s foaf:name ?o” statements.

Finally, one important trick to consider when LOAD-ing data in ARC2 is that when using LOAD <URI> on dereferencable URIs, the graph name will be the URI itself, which is confusing, especially if you want to define statements about the graph (i.e. provenance, creation date – as in this trigger – ). A simple solution is to define an arbitrary GRAPH URI based on the ressource URI itself, and then run LOAD <URI> INTO <GRAPH> as done on the previous snippet of code, which solves the problem and let you assign statements to the graph, and not to the URI itself.

Links to the triggers:

About these ads

2 thoughts on “Lightweight subPropertyOf / subClassOf inference with ARC2”

  1. Hi Alexandre, tnx for this post. I am using ARC2 at the moment and I’m looking for some OWL DL inference engine, but it seems like there ain’t much already available in the PHP domain, so I’m thinking of building one myself on top of ARC2.  Do you still have the trigger files available somewhere? The links don’t work anymore..  Just to have a nice example to get started with. 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s