RDFxt Abstract Syntax

Author:

Jonathan Borden jonathan@openhealth.org

This version:  March 5, 2002 

Latest version

Introduction

This document defines the Abstract Syntax for an extension of RDF [1] called for the moment RDFxt. This work is derived from an earlier proposal [8]. RDF Statements are commonly refered to as triples of [subject,predicate,object]. In practice it is useful to group triples into sets of statements termed: Bundles. This extension provides the ability to represent such Bundles or Contexts as collections of unasserted triples.

In RDF a statement is composed of a triple whose elements are URI references (URIrefs). In RDF a URIref forms a term in the domain of discourse. This extension defines term to be either a URIref, a Statement, a quantified variable, a literal or a Bundle.

In order to further discuss these terms it is useful to describe types, in particular note that constraints are placed on the type which a predicate may assume, this type is called a word.

Principle characteristics:

  1. Compact XML representation of s-expressions
  2. Compact XML representation of N3

Major changes to RDF:

  1. Statements are not automatically asserted
  2. Statements may nest other statements as the subject or object
  3. Bundles are ordered collections of terms
Shorthand RDF syntax:

the rdfx:aboutQ attribute is like rdf:about but has a QName as its value rather than URIref, likewise the rdfx:resourceQ attribute. This is used in examples here for clarity of reading.

word

A word is either a URI reference, a quantified variable or a literal. A literal is a string or quoted piece of XML.

word ::= (URIreference | variable | literal)

Note that an XML QName is used as shorthand for a URI reference and used interchangably with URI reference in this paper and its examples.

term

A term is either a word a statement or a bundle. 

term ::= (word | statement | bundle)

Statement

A statement is a triple composed of a predicate, a subject and an object.

statement ::= [subject,predicate,object]

Bundle

A bundle is a collection of terms. A bundle might be represented as an RDF collection.

the world ::= (bundle*)

bundle ::=   {term*}

variable

variable := ('?' Name) Name as defined in XML 1.0

predicate

A predicate is a word.

subject

A subject is a term.

object

An object is a term.

Purpose of the Bundle

The bundle allows separation of statements into lists which can be asserted as a group. Bundles allow 'coloring' of subgraphs. The document from which a set of statements arises forms a bundle (represented by its URI). Bundles can 'contain' other bundles.

Sentences

A sentence is generally a statement that contains a statement or bundle as its predicate or object i.e. it contains nested statements

Sentences are collected into bundles. A sentence is a subgraph which has as its root a statement that incorporates or nests other terms and sentences. The root or top level statements within a particular bundle are those statements which are not referred as the subject or object of any other statement within the context, that is they are direct elements of the bundle.

A language which is defined as an extension of RDF defines the syntactic structure and semantics of its sentences. The syntax may be defined in an extension of EBNF where "{" and "}" are used to delimit a bundle and "[" and "]" are used to delimit a statement:

S-Expression notation

A sentence is represented as an s-expression as:

s-expr ::= '(' term* ')'

An n-ary predicate is represented in s-expression notation as:

n-ary predicate ::= '(' predicate term* ')'

Note that in Statement form '[' subject predicate object ']' the first term is the subject but when in s-expression form: '(' predicate term* ')', the first term is the predicate.

XML representation

An n-ary predicate in s-expression form can be represented in XML form as:

<predicate> term* </predicate>

(not (if [color sky blue][color leaf green]))

<not>
   <if> 
  [sky color blue]
  [leaf color green]
   </if>
</not>

and then representing the statements as shorthand (QName) RDF/XML:

<not>
   <if> 
    <ex:color rdfx:aboutQ="ex:sky" rdfx:resourceQ="ex:blue"/>
    <ex:color rdfx:aboutQ="ex:leaf" rdfx:resourceQ="ex:green"/> 
   </if>
</not>
    
predicate: not - type URIref 
subject: (if [sky color blue][leaf color green]) - type  sentence 
  predicate: if - type URIref
  subject: {
    [sky color blue] - type statement
   [leaf color green] - type statement
  } type bundle
object: nil

n-ary predicate ::= '(' predicate term* ')'

the n-ary predicate is considered to have subject which is a bundle and object = nil

(or a b c d e f g)

<or>
   <a/>
   <b/>
   <c/>
   <d/>
   <e/>
   <f/>
   <g/>
</or>
predicate: or - type URIref
subject: {a b c d e f g} type bundle
object: nil
 

(If (And [sky color blue][leaf color green]] )(season summer))

<log:If>
  <log:And>
    <ex:color rdfx:aboutQ="ex:sky" rdfx:resourceQ="ex:blue"/>
    <ex:color rdfx:aboutQ="ex:leaf" rdfx:resourceQ="ex:green"/>
  </log:And>
  <ex:season rdf:aboutQ="ex:summer"/>
</log:If> 

 

It is important to note that the XPath expression:

/log:If/log:And/*

returns a NodeList of the children of the <And> element. This NodeList directly corresponds to the Bundle which is the subject of the predicate.

Queries as FOPL quantified variables

The Squish [2] query: (dc:creator, foo, ?x)(foaf:mbox, ?x, mailto:jonathan@openhealth.org)(foaf:surname, ?x, "Borden")

is represented as the bundle:

{

}

In the context of a query, variables are existentially quantified over the conjunction of the bundle



(exists ?x 
 (and {
  [foo, dc:creator,  ?x]
  [?x, foaf:mbox, mailto:jonathan@openhealth.org]
  [?x, foaf:surname, "Borden"]
  [?x, foaf:givenName, "Jonathan"]
   }
  )
)
   

Appendix: Representation of the N3 surface syntax as RDFxt

RDFx is intended to be suitable for service as an abstract syntax for N3. In particular, N3 contexts are represented as bundles.

From the N3 primer:

The formula: <x.rdf> :says {  :pat a :Person . } .

is representing as the RDFxt XML:

<rdf:Description rdf:about="x.rdf">
      <ex:says>
      <rdf:type rdfx:aboutQ="ex:pat" rdfx:resourceQ="ex:Person" />
      </ex:says>
</rdf:Description>

similarly the N3 Rule:

this log:forAll :x, :y. {:x :parent :y} log:implies {:y :child :x} .

is represented as the RDFxt sentence form:

(log:forall (log:vars ?x,?y) (log:implies [?x :parent ?y] [?y :child ?x]))

and in XML:

<log:ForAll>
    <log:vars><x/><y/></log:vars>
    <log:implies>
       <ex:parent rdfx:aboutQ="x" rdfx:resourceQ="y"/>
       <ex:child rdfx:aboutQ="y" rdfx:resourceQ="x" />
    </log:implies>
</log:forall>

Appendix: Implementation of bundles via RDF triples

Although this abstract syntax does not require a particular implementation, one might express a bundle as either a collection or list of triples.

bundles as collections

Expressed as a collection, each statement in a bundle is a member of the collection which represents the bundle. For example:

bundles as lists

The special predicate "rdfxt:etc" is used to indicate a list cell where the first element of the list is the subject and the rest of the list is the object. The special URI "rdfxt:nil" signals the end of a list.

(or a b c d e) -> [a or [b etc [c etc [d etc [e etc nil]]]]]

predicates are applied to a list as: predicate(first(list),rest(list))

  1. W3C RDF Model and Syntax 1.0
  2. ILRT Squish
  3. RDF DB
  4. 1
  5. N3
  6. Klyne's Contexts
  7. RDF in RELAXNG
  8. Proposed RDF Abstract Syntax