% GBNF specification of Normal LP with ur + roli's + queryelt, % corresponding to monolith DTD for RuleML V0.8 % by Benjamin Grosof % created 3/28/03 GBNF specification of: Normal LP (i.e., Normal Logic Programs), i.e., Hornlog plus negation-as-failure feature ("naf" or "fneg"), also with the URI constants feature ("ur"), and also with the object-oriented arguments collection feature ("roli's"), and also with the experimental feature of a query statement ("query") element that is defined in some other versions of RuleML V0.8 Hornlog, but omitting disjunction in the body and conjunction in the head ("ltao" feature), and omitting classical negation ("cneg") and courteous feature. This version corresponds to a restriction of the monolith V0.8 DTD for SCLP with ur and roli's. That DTD updates the SCLP DTD (known as "SCLP dtd-v13" or "sclp-v13") used in the first versions of SweetRules and SweetJess. This version is called "SCLP dtd-v14" or "sclp-v14". /* This version is somewhat sparse wrt design comments. But it includes comments that: - compare it to Hornlog V0.8 (file spec-hornlog+ur+roli-v08-monolith-v11.txt) - compare it to SCLP dtd-v13. - recommend design revisions and flag issues. */ /* Upper case denotes terminals. URI could be viewed as terminal, or one could add a macro equating/expanding it to CDATA. As in XML, CDATA is a string, and PCDATA is a string or markup. The rest (YES, NO, FORWARD, BACKWARD, BIDIRECTIONAL, BOUND, FREE) are tokens; each can be viewed as a fixed string. */ /* Note that left implicit below is a subtlety wrt restricting interleaving of sequencing. A macro symbol appearing in a containment rhs can be viewed as implicitly having an o-block (i.e., "[...]") around it. (See the description of GBNF for more discussion of interleaving and o-blocks.) E.g., consider the containment "atom : _opr , _args". "_args" here is a macro that may expand into multiple elements (e.g., multiple ind's). The element "_opr" is restricted to not be interleaved among the midst of these multiple elements; rather, it must appear either before all of them or after all of them. */ /* ISSUE: Note that one aspect of Courteous LP not represented here in the GBNF is the syntactically reserved status of the "overrides" predicate that specifies the prioritization (partial ordering) among (default) rules. This should probably be identified via use of the RuleML namespace, e.g., an instance rulebase should use "ruleml:overrides" and define the ruleml namespace as "http://www.ruleml.org". */ /* Overall, the main substantial difference in this version from SCLP dtd-v13 is that argument collections are supported, i.e., there are roli's and explicit tuples (i.e., tup's) */ %%%% rulebase : _rbaselab? , _statements , @direction , _rbschema ; _rbschema = @xmlns:xsi? , @xsi:noNamespaceSchemaLocation? ; /* @xmlns:xsi and @xsi:noNamespaceSchemaLocation optionally specify an XML Schema on the root element rulebase */ /* actually, these were not included in SCLP dtd-v13 */ /* recommend in revised design this be abstracted as a more general kind of schema specification, suitable for other concrete syntaxes / encodings (e.g., in OWL) as well. */ @xmlns:xsi : URI ; @xsi:noNamespaceSchemaLocation : URI ; @direction : inferencingdirection ; inferencingdirection = FORWARD | BACKWARD | BIDIRECTIONAL ; @direction $ BIDIRECTIONAL ; _rbaselab : ind | cterm ; /* issue for _rbaselab: should a label cterm restricted to be ground? */ _statements = (imp | fact | query | mutex)* ; /* compared to hornlog: more kinds of statements: mutex for Courteous features, sensor and effector for Situated features */ imp : _rlab? , _head , _body ; fact : _rlab? , _head ; /* issue: should a fact _head be restricted to be ground? ; some systems like to, others like not to */ /* usage issue: a fact can be represented as a rule with empty body */ query : _rlab? , _body ; _rlab : ind | cterm ; /* note for default reasoning cf. courteous LP, it is convenient to permit the cterm to be non-ground, mentioning variables that also appear in the head and/or body of the rule */ _head : classicalliteral ; /* compared to hornlog: AND (conjunction) is permitted in the head */ _body : literal | complexbodyexpr ; literal = classicalliteral | nafliteral ; /* compared to hornlog: literals are generalized to permit two kinds of negation sign: Negation As Failure (NAF) and a limited form of classical negation ("CNEG"), better viewed as "strong" negation. NAF may appear in the body. CNEG may appear in the head or the body. */ classicalliteral = atom ; nafliteral = flit ; complexbodyexpr = andbodyexpr ; /* compared to basic hornlog: body expressions are generalized to permit OR (disjunction), moreover nestedly with AND's, in the body */ andbodyexpr = andb | and ; /* ... | and is for down-compatibility */ orbodyexpr = orb ; andb : (literal | complexbodyexpr)* ; and : (atom)* ; /* recommend in revised design to eliminate and, replacing it by andb to improve elegance and up/down -compatibility */ /* actually, in SCLP dtd-v13 (SweetRules V1) the rhs is (atom | and)* which was motivated by down-compatibility */ atom : _opr , _args ; flit : _opr , _args , @fneg? ; @fneg : bool ; @fneg $ NO ; /* actually, in SCLP dtd-v13, @cneg and @fneg did not have a default value */ bool = YES | NO ; _opr : rel ; /* recommend in revised design to make this = not : and recommend likewise similarly for _opc */ _args = (logicalterm | argumentcollection)\* ; /* implicitly top-level is an ordered tuple */ /* recommend in revised design that rhs be simply argumentcollection */ /* actually, in SCLP dtd-v13, rhs was simply (logicalterm)\* */ logicalterm = ind | var | cterm ; argumentcollection = tup | roli ; rel : constname ; constname = PCDATA , @href? ; /* recommend in revised design that this be instead: constname = PCDATA | (@href , nick?) ; nick : PCDATA ; when there's a href, this would clarify meaning of the PCDATA as nickname for the URI and recommend likewise similarly for ind, ctor, arole, meth, clas, path, and any other constants */ @href : URI ; URI = CDATA ; var : PCDATA ; ind : constname ; cterm : _opc , _args ; _opc : ctor ; ctor : constname ; tup : (logicalterm | argumentcollection)\* ; /* implicitly at top-level is an ordered tuple. permits nested tup's and roli's, in spirit of complex data structures / Object-Oriented / Lisp S-expressions. */ roli : (_arv)* ; _arv : arole, (logicalterm | argumentcollection) ; arole : constname ; /* recommend in revised design: consider XML Schemas or OWL ontologies for the substructure of argument collections and complex terms */ /* Explanation of Abbreviations: rulebase = knowledge base of rules. direction = intended direction of inferencing. _rbaselab = rulebase label. Name of a rulebase. imp = implication rule. (Note it does not employ *material* implication cf. classical logic.) fact: Can be viewed logically as an implication rule that has an empty body. _head = head of a rule. A.k.a. the "consequent" or "then" part of the rule. _body = body of a rule. A.k.a. the "antecedent" or "if" part of the rule. _rlab = rule label. Name of a rule. andb = AND'd (i.e., conjunctive) expression permitted in the body. and = AND'd (i.e., conjunctive) expression - a particular kind that is permitted in the body. The "and" of some body atoms. Similar to andb, but simpler. Included for down-compatibility / back-compatibility, esp. with early versions of the Datalog and Hornlog sublanguages. atom = logical atom. An expression formed from a predicate applied to a collection of its (logical) arguments. _opr = relational operator expression. (This is for sake of upward expressive extensibility.) rel = relation. A logical predicate. var = variable. A logical variable. ind = individual. A logical individual. (Can be viewed logically as logical function whose arity is zero.) Negation-As-Failure (a.k.a. "Normal" or "Ordinary" LP) feature syntax follows: flit = negation-as-failure literal. A literal with negation-as-failure sign (fneg). fneg = negation-as-failure sign. The sign is either positive or negative. Negative ("YES" value of attribute) means negated. Positive ("NO" value of attribute) means unnegated, i.e., the same as if the negation symbol does not appear. bool = boolean. URI constants feature syntax follows: constname = (logical-) constant name. In this version, permits a URI. Complex (constructor) terms feature syntax follows: cterm = complex term. A logical term of the form "f(...)" where f is a ctor. _opc = constructor operator expression. (Similar in spirit to _opr.) ctor = constructor. A logical function. Object-oriented argument collections feature syntax follows: tup = tuple of arguments. An ordered collection of arguments. roli = role'd list of arguments. An unordered collection of arguments, with each member of the collecion being distinguished by an argument role name (arole). _arv = argument role-value pair. An argument (value) together with its indicating argument role (arole). arole = argument role. (See roli and _arv above.) "Query element" feature syntax follows: query = stored query specification. An EXPERIMENTAL feature. (If "query" element is indeed included in this version.) Note that in this DTD version, tup's and roli's can be nested. This is an EXPERIMENTAL aspect of the object-oriented argument collections feature. */