How to discover rules on the Web of Data?

Rules (in any form, such as N3, Jess, etc.) are an important building block of the Web of Data. Only recently, W3C has announced that RIF is the standard way to interchange rules on the Web.

Now, I'm wondering, how can one discover rules on the Web (of Data)? For example:

  1. Given a certain vocabulary, such as FOAF, find me all rules that use some FOAF terms.
  2. Given a certain relation, such as dcterms:author - what rules are there to infer new information?
  3. Based on non-functional requirements (such as license, rule language, etc.), which rules are available for, e.g. a certain schema mapping?

I'd love to see real-world examples of how to answer the above questions (preferably in SPARQL ;)

PREFIX rulz: <>
PREFIX rdfs: <>
PREFIX owl:  <>
SELECT ?ontology ?rule
  ?ontology a owl:Ontology .
  ?term rdfs:isDefinedBy ?ontology .
  { { ?rule rulz:inHead ?term . } UNION { ?rule rulz:inBody ?term . } }

For the discovery to be any use you need a common interchange format for rules so I'll answer this just in the context of RIF.

RIF allows Rules (and indeed atoms and other rule fragments as well as groups of rules) to be identified by URIs and to have accompanying metadata (expressed using RIF Frames which can then be mapped to RDF). Thus as RIF usage grows someone could run a harvester to aggregate such metadata and make it SPARQLable. So if rules were annotated with metadata such as license information, use of vocabularies etc. then you are sorted.

However, at least some of your examples (e.g. infers certain relations) are unlikely to be put in the metadata so we would then need to query over the rule structure. RIF is natively XML so this is possible using XQuery. However, there is also work ongoing on a RIF in RDF spec which would allow you to query RIF structures in SPARQL down to the finest of grains. The problem with this will be that there could be arbitrary length chains between the rif:Rule and the embedded expressions/atoms that you are tying to find. This will either need property chains from SPARQL 1.1 or you could use RIF itself to process the rules in RDF and propagate up metadata annotations which can then be discovered via simpler uniform SPARQL queries. Simple :)

Getting so many interchangeable rules out there that discovery is indeed a problem would be a major milestone!

The SPARQL Rules language SPIN ( uses an RDF syntax to store rules as part of linked data files. This makes it easy to publish and find rules in a consistent way (e.g. search for all usages of the property spin:rule). Furthermore, since spin:rules are attached to classes, it is easy to find all rules that are (likely) relevant to that class or its superclasses.

As Dave states above, the RDF syntax will require SPARQL list traversal operators to walk through the resources mentioned in a rule, but these are already supported by most SPARQL frameworks, ahead of the standard. SPIN is already widely used, but in most cases in the context of industrial projects that typically don't publish their ontologies on the open web, but just in local intranets or applications. That's why you may at this stage not find much.

Whether RIF will indeed become a relevant exchange format remains to be seen. For many use cases such as ontology mapping, SPARQL CONSTRUCT Rules are already a well established standard that has a huge user base and excellent tool support (triple stores etc).