Shorthand: Paths and Lists



Tim Berners-Lee



Decentralized Information Group
MIT Computer Science and Artificial Intelligence Laboratory

Semantic Web Tutorial

Shorthand: Paths and Lists

DanC, Sandro, and TimBL
$Id: index.html 2543 2007-01-10 03:14:52Z timbl $

Path-like phrases

An N3 expression for George's mother's assistant's home's address' zipcode:

[is con:zipcode of [
    is con:address of [
        is con:home of [
            is off:assistant of [
                is rel:mother of :George]]]]]

Special Syntax for paths

Shorter version of George's mother's assistant's home's address' zipcode using N3 path syntax:


kinda like javascript, python, and other object-oriented programming langauges

Backward traversal

You can do backward traversal, using "^" instead of "!" as punctuation. For example, if we know Dan's mailbox...

:dan con:mailbox <>

then we can write this expression for Dan:


Note: This is rather unlike javascript, python, and other object-oriented programming langauges

Paths (example with diagram)

Joe, Joe's mother, and somebody whose boss is Joe's mother:

graphviz source, diagram in SVG, Makefile

Variables in paths

If somebody has a mailbox whose URI ends with, then they're a W3C person:

 ?x a con:Person.
 ?x!con:mailbox!log:uri!str:endsWith ""
} => { ?x a :W3CPerson}

Some value, not the value

Note that there isn't necessarily only one match for a path - often there are many, when it is used on the left side of a rule.


would be "Some x such that I have parent x", and


would mean "Some y such that for some x, I had parent x and y had parent x", or loosely, some sibling of mine.

cwm only reads paths

Cwm doesn't currently use paths on output, so getting cwm to input and output a file will turn it into the form of N3 you already know.


(:x :y)

( :cust!bus:order!bus:number 
          !bus:number )

What lists are short for

[ rdf:first "y"; rdf:rest () ]
("x" "y")
[ rdf:first "x"; rdf:rest ("y") ]

What lists are short for (example)

( "Monday" "Tuesday" "Wednesday" )

short for

list diagram

Using lists for n-ary relationships

especially cwm built-ins:

(  "Dear " ?name " "," )   
             string:conatenation   ?salutation.

More Information

Creative Commons License
This work is licensed under a Creative Commons Attribution - Non-Commercial - No Derivatives 2.5 License.