W3C W3C Member Submission

SPIN - Overview and Motivation

W3C Member Submission 22 February 2011

This version:
Latest version:
Holger Knublauch <holger@topquadrant.com>
James A. Hendler <hendler@cs.rpi.edu>
Kingsley Idehen <kidehen@openlinksw.com>

This document is available under the W3C Document License. See the W3C Intellectual Rights Notice and Legal Disclaimers for additional information.


This document provides an overview of the SPARQL Inferencing Notation (SPIN). SPIN is a SPARQL-based rule and constraint language for the Semantic Web. SPIN is also a mechanism to represent reusable SPARQL queries as templates and to define new SPARQL functions with a web-friendly syntax.

Status of This Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document is part of the SPIN Submission which comprises three documents:

  1. SPIN - Overview and Motivation
  2. SPIN - SPARQL Syntax
  3. SPIN - Modeling Vocabulary

Earlier versions of the SPIN specification have been published by the informal SPIN working group at http://spinrdf.org

By publishing this document, W3C acknowledges that the Submitting Members have made a formal Submission request to W3C for discussion. Publication of this document by W3C indicates no endorsement of its content by W3C, nor that W3C has, is, or will be allocating any resources to the issues addressed by it. This document is not the product of a chartered W3C group, but is published as potential input to the W3C Process. A W3C Team Comment has been published in conjunction with this Member Submission. Publication of acknowledged Member Submissions at the W3C site is one of the benefits of W3C Membership. Please consult the requirements associated with Member Submissions of section 3.3 of the W3C Patent Policy. Please consult the complete list of acknowledged W3C Member Submissions.

The current stack of modeling languages for the web of data provide excellent mechanisms for capturing the static structure of data. SKOS [SKOS] can be used to describe concept hierarchies and vocabularies. RDF Schema [RDFS] and OWL [OWL] can be used to define classes, properties and relationships between these conceptual entities. While these languages define axiomatic definitions of data structures, describing general computational behavior of objects is not within the scope of these standards.

Object oriented languages provide well-known mechanisms for defining object behavior by describing classes and associating methods with class members. Object oriented methods often formalize how the modification of one attribute implies changes to other attributes. Another common purpose of methods is to capture constraints to ensure that the state of the objects remains within the bounds that the class designer had intended.

The SPARQL Inferencing Notation (SPIN) combines concepts from object oriented languages, query languages, and rule-based systems to describe object behavior on the web of data. One of the basic ideas of SPIN is to link class definitions with SPARQL queries to capture constraints and rules that formalize the expected behavior of those classes. SPARQL is used because it is an existing WC3 standard with well-formed query semantics across RDF data, has existing widespread use amongst most RDF query engines and graph stores, and provides sufficient expressivity for both queries and general computation of data. To facilitate storage and maintenance, SPARQL queries are represented in RDF triples, using the SPIN SPARQL Syntax.

The SPIN Modeling Vocabulary defines a collection of properties and classes that can be used to link RDFS and OWL classes with SPARQL queries. For example, the class ex:Rectangle can define a property spin:rule that points to a SPARQL CONSTRUCT query that computes the value of ex:area based on the values of ex:width and ex:height. Similarly, the property spin:constraint may link the class ex:Square with a SPARQL ASK query that verifies that the width and height values are equal. These properties follow existing SPARQL standards, and the execution of these constructs can be efficiently handled by any SPARQL processor. Since SPIN is entirely based on and represented in RDF, rules and constraints can be shared on the web together with the class definitions they are associated with. The attachment of rules to classes also encourages a style in which rules are locally scoped and thus easier to maintain, avoiding the spaghetti code of "flat" rule languages.

To support the modular abstraction of SPARQL queries, SPIN provides mechanisms to capture reusable SPARQL queries using SPIN templates, which are defined as SPARQL queries parameterized with pre-bound variables. This makes it possible to define higher-level modeling languages by defining text templates that specify variable values that are passed to the SPARQL queries as bound variables. Rules and constraints may be instances of those template calls. An example application area of SPIN templates is to extend existing rule profiles, such as OWL 2 RL, by defining the profile as set of SPIN templates and adding new rules through templates and SPIN rules. Other examples of SPIN template libraries have been published for checking constraints defined in the SKOS standard and other data quality constraints. These approaches demonstrate how SPIN can be used to transparently implement semantics by mixing standard RDFS and OWL definitions with generic, reusable rule libraries and application- or ontology-specific rules.

Based on the idea of templates, SPIN also makes it possible to define custom SPARQL functions. SPIN functions are formalized using a RDF vocabulary for describing a SPARQL function body in SPARQL and arguments passed to the function. SPIN functions can be shared on the web using their URIs, and SPARQL processors can dynamically look up function definitions on demand, such as in Web service calls. Whenever the SPIN function is used (e.g. in another SPARQL query), then the query body defined for the function will be executed. This mechanism makes it possible to build modular, complex SPARQL queries by combining other SPARQL query patterns. A good example of SPIN functions has been published in the context of ontology-based unit conversion.

Overall, we believe SPIN is an important contribution towards a web of data that can be more efficiently used by applications. SPIN builds on a mature, well-implemented SPARQL standard that facilitates development of semantic web applications. SPIN leverages object oriented principles such as encapsulation, components and procedural attachment to make it easier for machines and humans to understand, interact and process linked data resources.

Because of these benefits, we feel that recognition of SPIN as a W3C Recommendation will enable development of practical, portable, standards-based semantic web applications at both small and large scales.


We would like to acknowledge the many helpful suggestions from the user community of TopBraid Suite (e.g. via the TopBraid mailing list). Sincere thanks to members of the Jena team, in particular Andy Seaborne, for the implementation of the ARQ SPARQL engine that was crucial in the development of the SPIN reference API. We would furthermore like to acknowledge the contributions of many people at TopQuadrant, including Dean Allemang, Gokhan Soydan, Scott Henninger, Ralph Hodgson, Irene Polikoff, Bob DuCharme and Jeremy Carroll towards this specification.


OWL 2 Web Ontology Language: Document Overview W3C OWL Working Group eds. W3C Recommendation, 27 October 2009, http://www.w3.org/TR/2009/REC-owl2-overview-20091027/. Latest version available at http://www.w3.org/TR/owl2-overview/.
RDF Vocabulary Description Language 1.0: RDF Schema, Dan Brickley and R. V. Guha, Editors, W3C Recommendation, 10 February 2004, http://www.w3.org/TR/2004/REC-rdf-schema-20040210/. Latest version available at http://www.w3.org/TR/rdf-schema/
SKOS Simple Knowledge Organization System W3C OWL Working Group eds. W3C Recommendation, 18 August 2009.