% GBNF specification of Courteous LP with ur + roli's + queryelt, % corresponding to monolith DTD for RuleML V0.8 % by Benjamin Grosof % created 3/28/03 GBNF specification of: CLP (i.e., Courteous Logic Programs), with the URI constants feature ("ur"), and with the object-oriented arguments collection feature ("roli's"), and 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). Note CLP permits literals to be classically negated, in the manner of "extended" LP originated by Gelfond & Lifschitz. This is a limited sense of classical negation; it is actually expressively inessential. Let "cneg" stand for classical negation. For every predicate P, " cneg P " is essentially treated as if it were rewritten " P' ", where " P' " is a newly introduced predicate symbol. This version corresponds to a subset 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 = cslit | atom ; /* ... | atom is for down-compatibility */ nafliteral = fclit | flit ; /* ... | flit is for down-compatibility */ 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 ; cslit : _opr , _args , @cneg? ; /* actually, in SCLP dtd-v13, cslit was named clit */ fclit : _opr , _args , @cneg?, @fneg? ; flit : _opr , _args , @fneg? ; @cneg : bool ; @cneg $ NO ; @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 */ /* syntax for COURTEOUS follows. compared to hornlog: this is all added. */ mutex : _oppo , _mgiv? ; _oppo : ando ; /* recommend in revised design that this be = not : */ _mgiv : literal | complexbodyexpr ; /* recommend in revised design that this be = not : */ /* actually, in SCLP dtd-v13, rhs was (fclit | andb | orb), so this is more back-compatible */ ando : classicalliteral , classicalliteral ; /* note this requires cardinality 2, which is unusual, and thus requires care if/when doing a concrete syntax in OWL-Lite */ /* actually, in SCLP dtd-v13, rhs is simply (cslit, cslit) , which suffices for down-compatibility with hornlog */ /* plus: overrides is a syntactically reserved predicate that specifies the prioritization (partial ordering) among (default) rules. */ /* 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. "Extended" LP feature syntax follows: Note SCLP permits literals to be classically negated, in the manner of "extended" LP originated by Gelfond & Lifschitz. This is a limited sense of classical negation; it is actually expressively inessential. Let "cneg" stand for classical negation. For every predicate P, " cneg P " is essentially treated as if it were rewritten " P' ", where " P' " is a newly introduced predicate symbol. cslit = classically signed literal, a.k.a. classical literal. A literal with classical-negation sign (cneg). fclit = negation-as-failure classically signed literal. A literal with both classical-negation sign (cneg) and negation-as-failure sign (fneg). cneg = classical negation 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. 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. Courteous feature syntax follows: In Courteous LP, rules are treated as defaults, and prioritized conflict handling can be represented. Priorities between rules are represented via a binary predicate "overrides" which takes rule labels as arguments. "overrides" is syntactically reserved, but is otherwise an ordinary predicate - it can appear in general-form rules and be reasoned about, thus "overrides" facts can be inferred. Higher priority rules defeat lower priority rules. The prioritization ordering is a partial ordering. mutex = mutual exclusion statement (a.k.a. "mutex"). A mutex is a kind of integrity constraint, used to specify the scope of conflict in Courteous logic programs. It contains an opposer part and a given-condition part. The opposer part consists of two (classical) literals. The given-condition part is similar to a rule body. The mutex specifies overall that it is a prohibited contradiction for the two literals to be concluded if the given-condition part is concluded (i.e., holds). The semantics of Courteous LP enforces consistency with respect to this integrity constraint. A typical usage of a mutex is to specify that a predicate is (partial-)functional, e.g., that one should not conclude two different values for the price of the same item. OWL (and Description Logic) has the same notion of (partial-) functionality as something one can specify for properties. _oppo = opposer part of mutex. (See mutex above.) _mgiv = given part of mutex. (See mutex above.) ando = AND'd (i.e., conjuctive) expression permitted in the opposer part of a mutex. (See mutex above.) */