Created on 2016-04-26 15:01
Published on 2016-05-07 16:56
Brevity is a function of sophisticated use of language (systematic use of signs, syntax, and semantics for encoding information [data in some context]).
In this post (tweak of an earlier post on Medium) I demonstrate how a few RDF Language sentences about the British Royal Family can enable a SPARQL-compliant RDBMS, equipped with deductive capabilities, to produce inferred query results by way of reasoning & inference against the semantics (nature) of the predicates used in those same few sentences.
Courtesy of RDF Language based nanotation, in this case using Turtle Notation, I am able to use this post as a structured data source for the exercise at hand — that is, a demonstration of SPARQL Query Language-based reasoning and inference over snippets of data about the British Royal Family.
Image Source: http://cdn.playbuzz.com/cdn/03c85b38-12b0-4ccb-836f-e308516b383e/ea3dbf94-a959-4130-8710-86c3641c6b09_560_420.jpg
Here's a collection of sentences/statements that describe some of relationship types (relations) that connect various family members:
Loading the Raw Data in Virtuoso
Now that I have my raw data (here in the form of a Turtle-based collection of sentences/statements), I can load it into my SPARQL 1.1-compliant Virtuoso RDBMS using a variety of methods; for instance, I could even use the URI that Identifies this document (this blog post) in the FROM clause of a SPARQL query:
Setting Up Inference Rules
As suggested earlier, I am using terms from the relationship vocabulary to drive this exercise, which I will make Virtuoso aware of by performing a few additional steps.
First, I need to get the Relationship Vocabulary — a collection of RDF Language sentences that define a variety of relationship types — loaded into the Virtuoso instance behind our URIBurner service. There are two easy ways to do this:
— or —
2. Use a SPARQL 1.1 LOAD command—
In each case, the Sponger Middleware negotiates the content-format of the vocabulary (which may also be referred to as an ontology, schema, or data-dictionary) when retrieving this data from the originating server, en route to local RDF document storage.
You can check that the ontology has been successfully loaded using this SPARQL query —
Inference Rule Creation
Inference rules are created in the SQL realm of Virtuoso, by associating a uniquely identified Rule with a Vocabulary or Ontology that describes the existence and nature (semantics) of various entity relationship types. Here’s an example of such an association using a SQL command (calling the rdfs_rule_set(); stored procedure) that you can execute using any of Virtuoso’s data access interfaces (Command-Line iSQL, ODBC, JDBC, HTML-based iSQL, etc.) —
You can then verify the Rule’s Existence with the following SQL query —
Each of the following SPARQL query examples includes four elements:
Query 1 — Descendants of Elizabeth Bowes-Lyon (Queen Mother), without Reasoning & Inference
Query 2 — Descendants of Elizabeth Bowes-Lyon (Queen Mother) using Reasoning & Inference pragma
Query 3 — Descendants of Elizabeth Bowes-Lyon (Queen Mother), using
SPARQL 1.1 Property Paths feature
In this case, the inference & reasoning effect is crafted into the query, rather than being declared. Note: the unary operator “+” indicates a path of one or more occurrences of the relation in question (rel:ancestorOf) connects the relation subject (the Queen Mother) to one or more objects (descendants, in this case).
Query 4 — Prince Harry’s Sibling using Reasoning & Inference Pragma
You can comment out (using a leading “#” character) the Inference rule pragma (the DEFINE line) to disable the Reasoning & Inference effects (i.e., generation of inferred data).
Query 5 — Relationship Symmetry using SPARQL 1.1 Property Paths
Here, the unary operator “+” indicates a path comprised of one or more occurrences of the relation (rel:siblingOf) connecting the relation subject (Harry) to one or more siblings; while unary operator “^” indicates a path of one or more occurrences of the relation (rel:siblingOf) connecting the relation object (Harry) to one or more siblings; and the binary operator “|” provides the OR condition between “+” and “^”.
Query 6 — Queen Elizabeth II Ancestry with Reasoning and Inference
Query 7 — Queen Elizabeth II Ancestry with Reasoning and Inference using SPARQL 1.1 Property Paths
Query 8 — Descendants of Queen Elizabeth II, using Reasoning & Inference Pragma
Query 9 —Descendants of Queen Elizabeth II, using SPARQL 1.1 Property Paths to leverage the Transitive nature of rel:ancestorOf
The concept of a Deductive Database isn’t new; what’s different today is the existence of open standards (URIs, HTTP, RDF Language, OWL Ontology, and SPARQL) that enable implementation and delivery of this functionality in a standard form, as exemplified by OpenLink Virtuoso, our SPARQL compliant RDBMS that also includes scalable reasoning and inference functionality.
Being able to create, share, and consume semantically-rich data snippets is a critical requirement for a new generation of smart agents that will increasingly shape our experiences in regards to “Big Data”, “Semantically-enhanced World Wide Web” (a/k/a “Semantic Web”), and the burgeoning “Internet of Things.”