RDF Inference Language (RIL)



1. Abstract
2. Introduction
3. Expressions
3.1. Definitions

The RIL Specification RDF inference knowledge RIL 4RDF User's Guide to the RDF Inference Language

Abstract

RDF Inference Language (RIL) is a means of expressing expert systems rules and queries that operate on RDF models. RIL is an open format for complex queries on a directed graph knowledge representation.

Introduction

Warning: this is RIL version 0.1, which is still the one implemented in 4Suite, but it is not the most current RIL specification. Please see The RIL Page for more information.

Expressions

An expression is made up of a list of top level definitions. Definitions fall into two catagories, definitions that return a list of results, and those that don't. The results of the RIL expression are a list of all of the results from deinfitions that return results.

Talk about the workspace

Definitions

Rule

Rules are the heart of a RIL expression. Rules allow complex quering of the minder repository and executing a set of definitions on the results. Rules store queried values in skolem variables. Skolem variables are defined and modified in the premise of the rule. These variables are then in scope of the conclusion of the rule. If the skolem variable go out of context at the end of the rule.

A rule is made up of two parts, a premise and a conclusion. The premise is a series of RDF completes. An argument to a predicate can either be an unset skolem variable, a set skolem variable, a variable, or a constant. The predicate used in the complete is the fully qualifed name of the tag. If the premise has only argument, the argment is the subject of the complete. If the predicate has two arguments, then the second argument is the object in the complete. If an argument is not a skolem variable it must resolce to a list of strings. Each value in the list will be used in a complete. In a predicate with 2 arguments all combinations will be used. If the argument is a skolem variable the action is based on the type of predicate and wether or not the skolem variable was set in a previous predicate. If the skolem variable was not set by a previous predicate, then the skolem variable will contain the results from all of the completes. If the skolem variable was already set, then the action is dependent on the type of the predicate

One note, a not predicate cannot be evaluated if it uses a skolem variable that is un set.

Some premise examples.

Initial State of the Repository:
("user-1","title","molson")
("user-2","title","uogbuji")
("book-1","creator","user-1")
("book-2","creator","user-1")
("bool-3","creator","user-2")

RIL Expression
<?xml version = "1.0"?>
<ril:expression xmlns:ril = "http://namespaces.rdfInference.org/ril">
  <ril:rule>
    <ril:premise>
      <title>
        <ril:variable name='X'/>
        <ril:string>molson</ril:string>
      </title>
      <creator>
        <ril:variable name='Y'/>
        <ril:variable name='X'/>
      </creator>
    </ril:premise>
  </ril:rule>

State after execution
X = ['user-1']
Y = ['book-1','book-2']
  

More complex example

Initial State of the Repository:
("user-1","title","molson")
("user-2","title","uogbuji")
("book-1","creator","user-1")
("book-2","creator","user-1")
("bool-3","creator","user-2")
("book-1","genere","Sci-Fi")
("book-2","genere","Romance")
("bool-3","genere","Tecnical")


RIL Expression
<?xml version = "1.0"?>
<ril:expression xmlns:ril = "http://namespaces.rdfInference.org/ril">
  <ril:rule>
    <ril:premise>
      <title>
        <ril:variable name='X'/>
        <ril:string>molson</ril:string>
      </title>
      <creator>
        <ril:variable name='Y'/>
        <ril:variable name='X'/>
      </creator>
      <ril:not>
        <genere>
          <ril:string>Romance<ril:string>
        </genere>
      </ril:not>
    </ril:premise>
  </ril:rule>

State after execution
X = ['user-1']
Y = ['book-1']
  

Once all of the premises have been executed, the conclusions are evaluated. The conclusions are evaluated like all other definitions. Conclusions can contain all definitions except rules

Variable Actions

Certain actions reference and manipulate variables. RIL is a declarative language. A variable cannot be modified. If a varaibale is set and there is already a variable set with this name, a new variable will be created.

Variables can be passed in from the external world with the param tag.

<ril:param name="Foo">

The children of the param must resolve to a list. This list will be used as the default value if there is no parameter passed in

Variables can be referneced anywhere a list is expected. If a variable reference references a variable that has not been set, then an empty list will be returned.

<ril:variable-ref name="X"/>

Variables can be set to any list of strings. The children of the element must resolve to a list of strings.

<ril:variable-set name="X"/>
AssertActions

Assert actions are used to add content to the repository. When execution of an expression begins, the inference engine connects to the actual RDF repository and creates an in memory "temporary" repository. By default all asserts are placed in the current temporary repository. New tempoaray repositories are created and removed using the push and pop commands. The repository that the new assertion is added to can be changed with the optional depth attribute. The depth attribute is an attribute value template. If the depth is 0 or positive workspaces are indexed from the core repository (0) towards the current. If the depth is negative, repositories are referenced from the top temporary (-1) towards the core.

An assertion can take 1 or 2 arguments, both must resolve to lists of strings. In both cases the name of the tag is the predicate. In the case of only one parameter, the argument will be the subjects of the assertion and the object will always be 1. In the case of two arguments, the first argument will be the subjects, and the second argument will be the objects.

   <ril:assert>
      <tired><ril:string>Mike</ril:string></tired>
   </ril:assert>

   Will add the following triple to the temporary repository
   ('Mike','tired','1')
   

A Double argument example

   <ril:assert>
      <creator>
        <ril:string-list>
          <ril:string>Book-1</ril:string>
          <ril:string>Book-2</ril:string>
        <ril:string-list>
        <ril:string-list>
          <ril:string>Mike</ril:string>
          <ril:string>Uche</ril:string>
        <ril:string-list>
      </creator>
   </ril:assert>

   Will add the following triple to the temporary repository
   ('Book-1','creator','Mike')
   ('Book-2','creator','Mike')
   ('Book-1','creator','Uche')
   ('Book-2','creator','Uche')
   
Query Actions

Query actions are used to retrieve content from the minder. Parameters are resolved just like assertion parameters. However, skoloem variables can be used as wild card place holders


   Initial state of minder

   ('Book-1','creator','Mike')
   ('Book-2','creator','Mike')
   ('Book-1','creator','Uche')
   ('Book-2','creator','Uche')

   The Query:
   <ril:query>
     <creator>
       <ril:string>Book-1</ril:string>
     </creator>
   <ril:query>

   The results:

   [('Book-1','creator','Mike'),('Book-1','creator','Uche')]

   The Query:
   <ril:query>
     <creator>
       <ril:string>Book-1</ril:string>
       <ril:string>Mike</ril:string>
     </creator>
   <ril:query>

   The results:

   [('Book-1','creator','Mike')]
   
Progromatic Actions
    ril:if test = ""
    ril:choose
      ril:when test = ""
      ril:otherwise
   ril:method name=""
   ril:call-method name = ""
   
other Actions
   ril:subject
   ril:predicate
   ril:subject
   ril:paths
   ril:reverse-paths
   ril:index
   ril:sort
   ril:slice
   ril:reverse
   ril:intersection
   ril:union
   
Attribute Value Templates

Allow variable references. Number calculations

   $X > 1
   $X = $Y
   len($X) != 3
   "Foo" in $X
   $X + 15 < $Y
   
commands
   fire
   stop
   push
   pop
   depth
   message
   
Rdf complete
The set of statements from a subject, predicate and object query on the Rdf Repository. Any or all of the three components can be wildcards, in which case the result set will return all statements that match