APS

From RIF
Jump to: navigation, search

__NUMBEREDHEADINGS__


Document title:
RIF Abridged Presentation Syntax (Second Edition)
Editors
Abstract

This document, developed by the Rule Interchange Format (RIF) Working Group, specifies the non-normative abridged presentation syntax for the W3C Rule Interchange Format.

Status of this Document

Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.


1 Introduction

TBD

2 Direct Specification of RIF Abridged Presentation Syntax

2.1 Alphabet

The alphabet of the abridged presentation language consists of

  • a signature = < DTS, Pred, Frame, Act, =, #, ##, External, Const, ArgNames, arity, type >
  • a countably infinite set of variable symbols Var (disjoint from Const)
  • connective symbols And, Or, ¬ (negation), and :-
  • quantifiers Exists and Forall
  • the symbols Import, Prefix, and Base
  • the symbols Group and Document
  • the auxiliary symbols (, ), [, ], <, >, and ^^

2.2 EBNF

The hope is that the abridged syntax will become the BLD presentation syntax. To help the process, here is the entire EBNF for the abridged syntax as it evolves.

(Work in progress)

Note particular issues.


 Document   ::= IRIMETA? 'Document' '(' Base? Prefix* Import* Group? ')'
 Base       ::= 'Base' '(' IRI ')'
 Prefix     ::= 'Prefix' '(' Name IRI ')'
 Import     ::= IRIMETA? 'Import' '(' IRICONST PROFILE? ')'
 Group      ::= IRIMETA? 'Group' '(' (RULE | Group)* ')'
 RULE       ::= (IRIMETA? 'Forall' Var+ '(' CLAUSE ')') | CLAUSE
 CLAUSE     ::= Implies | ATOMIC
 Implies    ::= IRIMETA? FORMULA '->' (ATOMIC | 'And' '(' ATOMIC* ')')
 PROFILE    ::= TERM
 FORMULA    ::= IRIMETA? 'And' '(' FORMULA* ')' |
                IRIMETA? 'Or' '(' FORMULA* ')' |
                IRIMETA? 'Exists' Var+ '(' FORMULA ')' |
                ATOMIC |
                IRIMETA? 'External' '(' Atom | Frame ')'
 ATOMIC     ::= IRIMETA? (Atom | Equal | Member | Subclass | Frame)
 Atom       ::= UNITERM
 UNITERM    ::= Const '(' (TERM* | ('('Name  TERM)')')* ')'
 Equal      ::= TERM '=' TERM
 Member     ::= TERM 'TP' TERM
 Subclass   ::= TERM 'SC' TERM
 Frame      ::= TERM '[' (TERM '::' TERM)* ']'
 TERM       ::= IRIMETA? (Const | Var | Expr | 'External' '(' Expr ')')
 Expr       ::= UNITERM
 Const      ::= '"' UNICODESTRING '"^^' SYMSPACE | CONSTSHORT
 Name       ::= UNICODESTRING
 Var        ::= '?' UNICODESTRING
 SYMSPACE   ::= ANGLEBRACKIRI | CURIE
 IRIMETA    ::= '(*' IRICONST? (Frame | 'And' '(' Frame* ')')? '*)'
 ANGLEBRACKIRI ::= IRI_REF
 SYMSPACE   ::= ANGLEBRACKIRI | CURIE
 CURIE      ::= PNAME_LN | PNAME_NS
 Const      ::= '"' UNICODESTRING '"^^' SYMSPACE | CONSTSHORT
 CONSTSHORT ::= ANGLEBRACKIRI |             // shortcut for "..."^^rif:iri
               CURIE |                     // shortcut for "..."^^rif:iri
               '"' UNICODESTRING '"' |     // shortcut for "..."^^xs:string
               NumericLiteral |            // shortcut for "..."^^xs:integer,xs:decimal,xs:double
               '_' LocalName |             // shortcut for "..."^^rif:local

The EBNF grammar relies on reuse of nonterminals defined in the following grammar productions from other documents:

In this grammar, CURIE stands for compact IRIs [CURIE]. First, compact IRIs can be used for abbreviating symbol space IRIs, for instance it is allowed to write "http://www.example.org"^^rif:iri instead of "http://www.example.org"^^<http://www.w3.org/2007/rif#iri>, assuming that rif is a prefix defined for the IRI http://www.w3.org/2007/rif# in a respective prefix directive

Prefix( rif http://www.w3.org/2007/rif# )

in the preamble of the RIF document at hand [BLD].

Apart from compact IRIs, there exist convenient shortcut notations for constants in specific symbol spaces, namely for constants in the symbol spaces rif:iri, xs:string, xs:integer, xs:decimal, xs:double, and rif:local:

  • Constants in the the symbol space rif:iri can be abbreviated in two ways, either by simply using an absolute or relative IRI enclosed in angle brackets, or by simply writing a compact IRI. The symbol space identifier is dropped in both these alternatives. That is, for instance <http://www.example.org/xyz> is a valid abbreviation for "http://www.example.org/xyz"^^rif:iri; likewise, ex:xyz is a valid abbreviation for this constant, in case a respective prefix directive

    Prefix( ex http://www.example.org/ )
    

    is present in the preamble of the RIF document at hand.

  • Constants in the symbol space xs:string can be abbreviated by simply using quoted strings, i.e. "My String!" is a valid abbreviation for the constant "My String!"^^xs:string (which in turn is itself an abbreviation for "My String!"^^<http://www.w3.org/2001/XMLSchema#string>).
  • Numeric constants can be abbreviated using the grammar rules for NumericLiterals from the [SPARQL] grammar: Integers can be written directly (without quotation marks and explicit symbol space identifier) and are interpreted as constants in the symbol space xs:integer; decimal numbers for which there is '.' in the number but no exponent are interpreted as constants in the symbol space xs:decimal; and numbers with exponents are interpreted as xs:double. For instance, one could use 1.2 and 1 as shortcuts for "1.2"^^xs:decimal and "1"^^xs:integer, respectively. However, there is no shortcut for "1"^^xs:decimal.
  • The shortcut notation for rif:local applies to only a subset of the lexical space of syntactically valid lexical parts of constants in this symbol space: We allow "_"-prefixed unicode strings which are also valid XML NCNames as defined in [XML-NS]. For other constants in the rif:local symbol space one has to use the long notation. That is, for instance _myLocalConstant is a valid abbreviation for the constant "myLocalConstant"^^rif:local, whereas "http://www.example.org"^^rif:local cannot be abbreviated.

Editor's Note: We might introduce additional shortcuts, e.g. for rif:text in future versions of this draft.

3 Mapping to Full Presentation Syntax

The abridged presentation syntax maps to the RIF dialect's full presentation syntax as follows:

Full presentation syntax Abridged presentation syntax Remark
"foo:bar"^^rif:iri foo:bar CURIE Syntax 1.0
"purchase"^^rif:local _purchase locality by default
"a b c"^^xs:string "a b c" full quotes are part of syntax
"a b c@en"^^rif:text "a b c"@en text with explicitly specified language
"10"^^xs:integer 10 as in programming languages
"1000000000"^^xs:long 1000000000 as in programming languages
"3.14"^^xs:decimal 3.14 as in programming languages
External(pred:numeric-less-than(1 2)) 1 < 2 ">" "<" "!=" "=" "<=" ">=" as in programming languages
External(func:numeric-subtract(2 1)) 2 - 1 "+" "-" "*" "/" as in programming languages
External(pred:isInteger(?x)) ?x^^xs:integer typed variables as in typed languages instead of guards
External(func:lower-case("ABC")) $func:lower-case("ABC") $ denotes an external (built-in) function or predicate call
If [Conditions] Do [Actions] [Actions] :- [Conditions] for production rules in PRD
Forall [Vars] [Conclusion] :- And([Conditions]) [Conclusion] :- [Conditions] for derivation rules in BLD

Editor's Note: Currently we use :- from the ISO Prolog syntax in the abridged presentation syntax as sign to distinguish the head of a rule from the body of a rule. However this might change to [Conditions] => [Actions] | [Conclusion]

Additionally, the following conventions are used in the abridged presentation syntax:

  • If not explicitly stated variables are universially quantified (Forall)
  • If not explicitly stated we assume conjunction (And) (instead of disjunction)
  • If not explicitly stated we assume an assert action (Assert) for production rules
  • To denote the end of a rule we use "."

4 Appendix: Examples

TBD