From W3C Wiki
Revision as of 05:33, 17 January 2005 by (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

RDF has explicit support for binary relations (properties) and unary relations (classes), but some relations are naturally NaryRelations; e.g. "Chicago is between New York and Los Angeles."

So make a list of all but one of the terms in the relation:

  :Chicago :between ( :LosAngeles :NewYork ).

We can query this as an open-ended list:

   ?middle :between ?list.
   ?list first ?city1.
   ?list rest ?a.
   ?a first ?city2.

or more succintly as a closed list:

   ?middle :between ( ?city1 ?city2 ).

The decision about which way to query this should come from the semantics of :between. If it is guaranteed that slots added in the future will not impact the interpretation of the earlier arguments to the :between predicate, we can use the former (more verbose) query. There is no machine-readable way to make this guarantee, though it is consistent with one of the principals of RDF.

If this guarantee is not made, we can forget about applying our understanding of :between to any variation with more slots so we must use the later (more succinct) query to view :between data only in the anticipated form. In fact, the publisher of :between data with more slots would probably @@opinions?@@ be violating the stated range constraints of :between as the list ( :LosAngeles :NewYork ) is assumed to have no relationship to ( :LosAngeles :NewYork :foo ).

For example, we may wish to extend this relation to include a directness quotient (efficiency of going from city1 to city2 via "between" city):

  :Chicago :between ( :LosAngeles :NewYork 0.89 ).

Only the open list query would match this data:

   ?middle :between ?list.
   ?list first ?city1.
   ?list rest ?a.
   ?a first ?city2.

because the cdddr of the list is nil in the old :between assertion and ( 0.89 ) in the extended form.

Functions of more than one argument work fairly well using this pattern; e.g. in the Cwm built-in functions.

	( 1  2 3 ) math:sum ?x.

using NotationThree here.