The courteous layer introduces prioritized conflict handling. Four new features are introduced into the syntax:
The theory behind the courteous logic programs is described in [Grosof2004a, Grosof99a].
The courteous layer builds upon the NAF layer of SWSL.
Rule Labels: Each rule has an optional label, which is used for specifying prioritization in conjunction with the prioritization predicate (below). The syntactic form of a rule label is a term enclosed by a pair of braces: { ... }. Thus, a labeled rule has the following form:
{label} head :- body.
A label is a term, which may have variables. If so, these variables are interpreted as having the same scope as the implicitly quantified variables appearing in the rule expression. E.g., in the rule
{specialoffer(?X)}
pricediscount(?X,tenpercent) :- loyalcustomer(?X).
the label specialoffer(?X)
names the instance of the
rule corresponding to the instance ?X
.
However, the label term may not itself be a variable, so
the following is illegal syntax:
{?X}
pricediscount(?X,tenpercent) :- loyalcustomer(?X).
In general, labels are not unique; two or more rules (or instances of rules) may have the same label term. However, often it is convenient to specify rule labels uniquely within a particular given rulebase.
Classical Negation: The classical negation
connective, neg
, is permitted to appear within the head
and/or the body of a rule. Its scope is restricted to be an atomic
formula, however. Thus classical negation is restricted to appearing
within a classical literal. For example:
neg boy(?X) :- humanchild(?X) and neg male(?X).
{t14(?X,?Y)}
p(?X,?Y) :- q(?X,?Y) and naf neg r(?X,?Y).
However, the following example is illegal syntax because neg
negates a non-atomic formula.
u(?X) :- t(?X) and neg naf s(?X).
Note that the classical negation connective (neg
) is also used in
SWSL-FOL, the first-order subset of SWSL-Language. However, the semantics of
classical negation in Courteous LP (and thus SWSL-Rules) is somewhat weaker
than in FOL (and thus SWSL-FOL).
Prioritization Predicate:
The prioritization predicate
_"http://www.ruleml.org/spec/vocab/#overrides"
specifies the prioritization ordering
between rule labels, and thus between the rules labeled by those rule labels.
The name of the prioritization predicate is syntactically reserved.
In this document we will use the following prefix declaration
prefix r = "http://www.ruleml.org/spec/vocab/#"
and abbreviate the prioritization predicate using the sQName
r#overrides
.
In the future, we might adopt a different prefix, such as
"http://www.swsi.org/swsl/reserved/#"
.
A statement r#overrides(label1,label2)
indicates that the first
argument, label1
, has higher priority than the second argument,
label2
. For example,
consider the following rulebase RBC1:
{rep} neg pacifist(?X) :- republican(?X).
{qua} pacifist(?X) :- quaker(?X).
{pri1} r#overrides(rep,qua).
Here, the prioritization atom r#overrides(rep,qua)
specifies that rep
has higher priority than qua
.
Continuing that example, suppose the rulebase RBC1 also includes the
facts:
{fac1} republican(nixon).
{fac2} quaker(nixon).
Then, under the courteous semantics, the literal
neg pacifist(nixon)
is entailed as a conclusion, and the literal
pacifist(nixon)
is not entailed as a conclusion,
because the
rule labeled rep
has higher priority than the rule labeled
qua
.
The prioritization predicate r#overrides
, while its name is
syntactically reserved, is otherwise an ordinary predicate -- it can appear
freely in rules in the head and/or body. This is useful for reasoning about
the prioritization ordering.
Mutual exclusion (mutex) statements: The scope of what constitutes conflict is specified by mutual exclusion (mutex) statements, which are part of the rule base and can be viewed as a kind of integrity constraint. Each such statement says that it is contradictory for a particular pair of literals (known as the "opposers") to be inferred, if an optional condition (known as the "given") holds true. The courteous LP semantics enforce that the set of sanctioned conclusions respects (i.e., is consistent with) all the mutexes within the given rulebase. Common uses for mutexes include specifying that two unary predicates are disjoint, or that a relation is functional; examples of these uses are given below.
A mutex without a given condition has the following syntactic form:
!- lit1 and lit2 .
where lit1
and lit2
are classical literals.
Intuitively, this statement means that it is a contradiction to derive both
lit1
and lit2
.
For example:
!- pricediscount(?CUST,fivepercent) and pricediscount(?CUST,tenpercent).
says that it is a contradiction to conclude that the discount offered
to the same customer ?CUST
is both fivepercent
and
tenpercent
. As another example,
!- lion(?X) and elephant(?X).
specifies that it is a contradiction to conclude that the same individual is both a lion and an elephant.
A mutex with a condition has the following syntactic form:
!- lit1 and lit2 | condition .
Here
condition
is syntactically similar to a rule body,
and lit1
and lit2
are classical literals.
The symbol "|
" is a language keyword, which separates the
oposing literals from the condition. For example:
!- pricediscount(?CUST,?Y) and pricediscount(?CUST,?Z)
| ?Y != ?Z.
says that it is a contradiction to conclude that the discount offered
to the same customer, ?CUST
, is both ?Y
and
?Z
if ?Y
and ?Z
are distinct
values. This means that the relation
pricediscount
is functional.
Courteous LP also assumes that there is an implicit mutex between
each atom A
and its classical negation
neg A
. This implicit mutex is also known as
a "classical" mutex.