^ x\|^ HD28 .M41A i^ Business MIT uL MIT Sloan School of Management Sloan Working Paper 4187-01 eBusiness@MIT Working Paper 113 October 2001 A DECLARATIVE APPROACH TO BUSINESS RULES IN CONTRACTS: COURTEOUS LOGIC PROGRAMS IN XML Benjamin Grosof, Yannis Labrou, Hoi Y. Chan This paper is available through the Center for eBusiness@MIT web site at the following URL: http://ebusiness.mit.edu/research/papers.html This paper also can be downloaded without charge from the Social Science Research Network Electronic Paper Collection: 94 http://papers.ssm. com/abstract_id=2 9 A Declarative Approach to Business Rules in Contracts: * Courteous Logic Programs in XML IBM T.J. Benjamin N. Grosof Watson Research Center, P.O. Box 704, Yorktown Heights, NY 10598, grosof@us ibm. com (alt.: grosof @cs .Stanford, edu) USA . http //www research ibm. com/people/g/grosof . : . Yannis Labrou Computer Science and Electrical Engineering and Department 21250, USA University of Maryland, Baltimore County, Baltimore, klabrouOcs MD edu http //www. cs .umbo edu/~ jklabrou/ j . T.J. . . : IBM urnbc Hoi Y. Chan Watson Research Center, RO. Box 704, Yorktown Heights, NY USA 10598, hychanOus ibm com . . Abstract forms any CLP into a semantically equivalent OLP with moderate, tractable computational overhead. We address why, and especially how, to represent business rules e-commerce in we mean tracts, By contracts. Second, con- suitable offered or sought, including ancillary agreements detailmg tenris of a deal. We sions, observe that rules We such & conditions, service provi- contracts. in The interchange between heterogeneous BRML can also ex- Knowledge In- Our new approach, unlike previous approaches, provides not only declaratives emantics but also with several examples. rules for terchange Format (KIF) which overlaps with CLP, prioritized conflict handling, ease of parsing, and analyze requirements (desiderata) for repre- senting new XML encoding of CLP, Markup Language (BRML), press a broad subseto f ANSI-draft and surrounding business processes, and we illustrate this point give a commercial rule languages. are useful in contracts to represent conditional rela- tionships, e.g., in terms we called Business Rules descriptions of goods and services integration into require- ments mclude: declarative semantics so as ing. to en- We WWW-world argue that this software engineer- new approach meets the able shared understanding and interoperability; pri- overall requirements to a greater extent than any modu- of the previous approaches, including than KIF, the oritized conflict handling so as to enable lar updating/revision; into WWW-world leading previous declarative approach. ease of parsing; integration We software engineering; directe x- have implemented both aspects of our ap- ecutabihty; and computational tractability. proach; a free alpha prototype called We Rules was released on the give a representational approach that consists of two novel aspects. First, we give a new in July Commonof 1999, at http //alphaworks ibm. com. fun- damental knowledge representation formalism: Web . : An a generalized version of Courteous Logic Programs extended version of this paper will be avail- IBM Research Report http //www. research ibm. com). able as afo rthcoming (CLP), which expressively extends declarative or- : (at . dinary logic programs (OLP) to include prioritized conflict handling, thus enabling modularity in spec- ifying and revising plementing CLP is rule-sets. a Our approach 1 to im- courteous compiler that trans- One form of commerce Copyright ACM. To appear: Proceedings of the 1st Conference on Electronic Commerce (EC99), to be held Denver, 3-5, Colorado, USA, Nov. 1999. Edited by Michael R Wellman. New York, NY: ACM ACM Press, 1999. http://www.ibm.com/iac/ec99/ hccp; //www. acm.org. Introduction or automation is that could benefit substantially from contracting,wh ere agents form binding.a gree- able terms, and then execute these terms. mean initially parties in the Economics By "agents", we sense, e.g., as buyers or sellers; however, once automated, these agents might be intelligent agents in the Computer Science sense. agreements, delivery schedules, conditions for returns, usage we make a sharp distinction between the repremechanism for communicating contract rules, and the actual rule execution mechanisms employed by participating agents. Our concern here is with the former, though of course in designing a communication mechanism one must good or service consider and anticipate the requirements of execution to be By e-commerce scriptions we mean "contracts", broad sense: de- in a otgoods and services offered or sought, along with & applicable terms of tailing teniis conditions, a deal. i.e., ancillary agreements de- Such terms include customer service and other issues relevant restrictions, to the Such descriptions are fronts, as well as in bids to be found in We catalogs and store- and requests communicated by (e.g., agents) during negotiations, procurements, and auctions. overall contracting process comprises several stages, Discovery: Agents find potential contracting partners. approach will take a declarative By contracts. to business rules in "declarative" semantics for rules, we mean sense of knowledge representation (KR) theory, in the including broadly: 1 that performed by each of the agents. provided. The Note sentational in a manner abstracted away from the choice ofim plementation approach: the semantics say which conclusions are entailed model-theoretically) by a given set of premises, with- (e.g., out dependence on procedural or control aspects of inference 2. Negotiation: Contract terms are detemiined through a process of communication between agents, often involving iterative modification of the contract terms. 3. Execution: We observe that many is used to mean any kind of By significant ap- computing an (i.e., the IF part) (i.e., AND'ed) we mean more "rule" in this paper, specifically an implication (i.e., may IF-THEN) rules, of- (Sometimes, plication logic, e.g., the algebraic formula for insurance annuity. Example Roles for Rules Conflict Handling contract terms involve conditional ten called business nileso r business policies. tecedent is backward versus forward. 2 and can conveniently be expressed as "business rule" from whether the direction of rule inferencing Transactions and other contract provisions are executed by the agents. relationships, away algorithms. In particular, declarative semantics abstract in which the an- contain multiple conjoined Next, we and Prioritized give a few brief examples, expressed As we guage, of business rules in contracts. in natural lan- go, conflict, and the opportunity — because of Example A typical we will see — because of both the need for prioritized conflict handling for prioritized conflict handling naturally available prioritization information. (Refund Policy) 1 example of a seller's refund policy is: conditions.) For example, rules are useful • (Rule A:) "If buyer returns the purchased in describing: good any for reason, within 30 days, then the purchase amount, minus • terms & conditions, e.g., rules for price discounting; • surrounding business processes, to place 10% a • service provisions, e.g., rules for refunds; and lead time is an order. defective, within will We believe that B Rule many fiinded". in automated contracts. In this Here, work we are concerned primarily with the negotia- tion stage of contracting, and specifically with how to repreit sent business rules in contracts. The contract terms may or may not be modified during may be tance. Crucial during negotiation, however, tract the a rel- communication followed by accep- must understand and agree. In is thatal 1 (More year, then the full purchase "If both Rules i.e., say a rule "applies" is satisfied. The when 30 days. In this case, a common generally, body be (i.e., re- an- necessary because Rules A and B it is de- conflict incompatible with each other. The conflict ority: Rule B is is resolved by pri- specified to have higher priority than Rule A. agents some agents might the scope of this paper.) a shared language with understanding of rules which agents can reach in contracts, rules are relatively easily modifiable, executable by the agents. is will with each other; both rules apply but their consequents are Example 2 (Lead Time) In business-to-business commerce, minimum advance beyond amount can happen that the buyer returns the good because man is and B apply, then that rule's Priority Rule be human, as well as automatic; however, the aspects of hu- Our goal A the full purchase supply chains, sellers often specify interaction are it amount terms of automation, the con- has to be communicated and digested by each agent, with shared semantics. 'wins', fective within negotiation stage. If not, the negotiation stage atively simple process of we tecedent) I be refunded." • (Priority Rule:) rules as an overall representational approach capture well aspects of what one would like to describe good because • (Rule B:) "If buyer returns the purchased e.g., rules for (Section 2 elaborates on these examples.) restocking fee, will be refunded." such that the communicatable, and e.g., in manufacturing how much lead time, required in order to place or modify a purchase order. example of a parts supplier vendor's lead time policy • (Rule A:) "14 days lead time customer." i.e., notice before scheduled delivery date, if the buyer is is An is: a preferred • (Rule B:) "30 days lead time minor backlogged is the ordered item's itein- it": vendor, and the order at the is a 'wins', "II' sponding bids, often involve conditional relationships A Rules between price, quantity, and delivery date, e.g., "If is between 400 and 1000 units, and and C both apply, then Rule pleased to have IS Rules A, B, and appK the order quantity C flict more is ever, the having trouble m the product catalogs, many properties of a product are above between them when information - more • its In ties at how modem". XS, able in sizes con- common of that product, rather than being particular internal How- to resolve E.g., "all V-neck sweaters and black". are available in fabrics acrylic authorization are often naturally expressed Example 3 (Bookstore Personalized Discounting) sufficient and/or necessary conditions. today among e-commerce A and • Policies about creditworthiness, trustworthiness, priority to resolve all potential conflicts. interest in- and cashmere". moment during the process of may be insufficient justified Sellers often provide personalized price discounting. an women's T-shirts are availM, and L", "all men's T-shirts are M, L, XL, and XXL", and "all T- shirts are available in colors navy, khaki, sit- incremental specification, there of considerable to E.g., "all S, available in sizes S, B, for example; no relative priority any given unit.". dividual product. E.g., "all laptop computers include an accumulate over time, or are specified by rules multiple authors: and 30 daysfro most naturally specified as conditional on other proper- rationale might be that recent, than Rule A. specified as yet. This reflects a is 15 $48 per is buyers) for the item, and rule-set leaves unspecified A and between is order date, then the price two or three of them might conflict: specific, or between Rules uation is buyer relieve the pressure. this C may all its vendor given purchase order. The Priority Rule provides to a partial prioritization Rule that the is orders (from filling its overall thus C AAA example above • In supply chain settings: requests for proposals, and re- the delivery date The hotel discounts for in feel to the about personalized discounting. mod- days lead time," i.e. ,2 rationale for Rule e.g., members, are often similar a preferred customer." • (Prioriis Rule:) C about discounting for groups or preferred • Policies a reduce the quantity of the item, and the buyer ification to is is customer organizations, • (Rule C:) "2 days lead time type the ordered item if part." in terms of Such conditions include: credentials, e.g., credit ratings or professional topic certifications; third-party sellers recommendations; properties is of a transaction how to do this more cheaply and uniformly by automating it. An e.xample of a bookstore's personalized discounting policy in question, e.g., its size or mode of pay- ment; and historical experience between the agents, e.g., familiarity or satisfaction. is: • (Rule A:) "5 percent discount if buyer has a history of loyal spending at the store." • (Rule B:) "10 percent discountif buyer has a history of big spending at the store." Rule Representations: Previous Approaches including KIF, Requirements Analysis In section (Rule D:) "10 percent discount if buyer is a member of standing of rules • (Rule E:) "No discountif buyer has a late-payment his- tory during the last year." (Priority Rules:) is "B is A and than C A all and than C; E the othis higher Here, the Priority Rules specify a set of priority comparisons, (i.e., among the rules. many underre rela- communicatable, and executable analyze and elaborate these require- for Rules contract terms can be well represented We tion for our approach. begin by reviewing previous ap- proaches. mented commercial use erally (not for contracts in particular). code constructs in programming languages such is Prolog [3], a lated to Prolog, is SQL One approach is as C, C++, and rules. A rules. views. In di- Java'. second ap- programming language oriented to- A third approach, closely reSQL-type • Policies about cancelling orders are often similar in feel examples above about refunds and lead time. wide imple- general-purpose imper- Other approaches are more specific to proach in for representing business rules gen- wards backward-chaining as rules. to the which we bold-face desiderata, or throughout this section) for a rule representation, and discuss ative believe that we criteria rectly as if-then More Example Roles a shared such that the rulesa There are multiple approaches already and than D." that are sufficient to resolve all the potential conflicts We in contracts, is common candidate previous approaches in light of them, as motiva- higher priority than higher priority than priority than work our goal by the agents. ments D stated that in this In this section, the store's Platinum Club." ers; we tively easily modifiable, card." • 1, language with which agents can reach a • (Rule C:) "5 percent discount if buyer has a store charge • 3 'trademark of Sun Microsystems Inc. relational database systems [22] a view is coiiJiiion-action rules kind found to "active rules" I SQL views, is eveni- "triggers" [22] of the / many database systems and in A defined, in eflect, by a set of rules. approach, fairly closely related fourtli routing systems. These are forward-directed, triggered by events such as updating a database relation. A fifth approach is production rules, a form of forward-chaining approaches as well, e.g., in of the kind rules, 0PS5 system tems descended from the [4]. in sys- There are other expert systems, knowledge-based systems, and intelligent agent building tools, but the above- probably the currently most commercially impor- listed are tant, especially A m e-commerce. approach sixth edge Interchange Format (KIF)^. KJF Rather, is KIF Knowl- not a directly ex- language for a is is in- terchange of knowledge, including rules, between heteroge- neous software systems, convenience convenience More e.g., agents. precisely, a prefix' version of first-order predicate calculus An important aspect of expressive power i.e., rules that KIF is (i.e., first- in several other munication, e.g., is IF, cur- standards committee process. is also being considered infor- standards efforts relevant to agent FIPA^'.K however, not yet is com- wide im- in plemented commercial use. Next, we One group of requirements revolves the ability to is are default rules. important to conveniently express pri- oritized conflict handling, where some i.e., rules are sub- by higher-priority conflicting rules, such as by special-case exceptions, by more-recent updates, or by examples As we saw in our contract rule-set and the need/opportunity in section 2, conflict, for prioritized override, frequently arise. Most commercially important rule systems (including the above-listed widely implemented approaches) monotonic reasoning as an employ non- highly-used feature. essential, employ some form of negation-as-failure. Ofemploy some forni of prioritized override between e.g., the static rule sequence in Prolog or the computed Typically, they rule-activation sequence/"agenda" in 0PS5-heritage production rule systems. modern software In vital aspect design, is it widely recognized that a of modifiability ismod ularity and locality in revision, e.g., in the manner itized conflict cation and and informa- that subclassing tion hiding provide in object-oriented elaborate on requirements and relate them to the previous approaches. is it ject to override rules, KJF of classical higher-order logic) and definitions. mally employ negation-as-failure or In particular, operator (thus enabling additional expressiveness akin to that Supporting or endorsing KIF process of specification. Expressive an aspect of expressive power, but also conveniently express rules that are logically non-monotonic, ten they ANSI for the in part implies the need for conceptual naturalness of semantics. order classical logic) with extensions to support the "quote" rently well along in the is higher-authority sources. for representing business rules ecutable representation. Ease of modifiability implies the requirement of expressive programming. Prior- handling enables significantly easier modifi- more modular revision/updating. New behavior around heterogeneity. Specifically, the multiplicity of widely can be specified more often by simply adding rules, without implemented approaches implies an immediate requirement needing to cope with heterogeneity of implementations of busi- ness rules. The communicate with shared under- ability to standing then implies the requirements of interoperability to modify the previous ous general-case case rule. This rule, is with declarative semantics. The above-listed widely imple- in object-oriented mented approaches lack needing fully declarative semantics. Communicatability and interoperability imply the require- ment of ease of parsing Interoperability cated. rule-sets that are being and practical executability requirement of integration into gineering overall. The tates A XML WWW-world communiimply the software en- aspect of ourapp roach facili- overall requirement more is expressive power in specific- to modify without needing to modify the general- similar to the modular/local gracefulness programming of adding a subclass without the superclass. Another important aspect of expressive power, tion to practical executability, is in rela- the ability to conveniently express procedural attachments. Procedural attachments are the association of procedure calls with belief expres- Example sions, e.g., in 1, the association of the Java . second group of requirements revolves around expres- A basic E.g., a CustomerAccount setCredi tAmount such parsing and integration. siveness. rules. case rule can be added and given higher-priority than a previ- cal predicate refund. Procedural attachments method with the logiare crucial in order for rules to have actual effect beyond pure-belief in- specifying rules. Practical executability, however, implies the ferencing, e.g., forac tions to be invoked/performed as a re- strong desire for computational tractability in the sense of sult after rule Expressive power average-case and worst-case complexity. to listed ^http //logic Stanford. edu/kif / and http //www. cs umbo .edu/kif/ ^The specification current draft ANSI of KIF (http //logic Stanford. edu/kif /dpans .html) also Procedural attach- invoke procedure calls when rule conditions are tested/queried. has to be balanced against tractability. Almost all of the above- widely implemented approaches include procedural at- . : tachments. . : . : includes an infix version of KIF intended automated exchange. "Foundation for Intelligent for human consumption rather than http //www : conclusions are inferred. ments are also very useful . f ipa . org Physical Agents: However, procedural attachments are semantical ly probis how to give them lematic, and an open research issue today a semantics that abstracts and is away from implementation details thus akin to being declarative. (See the discussion of Situated Logic Programs in section 5.) com- we have here further expressively generalized, notably to han- response to the need to cope with implemen- dle pairwise mutual exclusion K.IF has been developed specifically for puqioses of munication, in tational heterogeneity of rules and other knowledge. By con- with the abo\e-listed widely implemented approaches, trast KIF has a fully declarative intended strength. Its is 4.1 We and compu- logically monotonic, highly expressive, is is its focusing on first-order logic. First-order sical logic, primarily logic main based on clas- semantics; indeed, that declarative semantics perform inferencing) for the general tationally intractable (to case a broad class of rules. However, it has several important shortcomings as a language for business rules in e-commerce, including KIF has crucially, a Perhapsm in contracts. shortcoming of edge representation (KR): KR tal its fault rules, and prioritized conflict handling;KI F logically is monotonic. KIF also cannot (conveniently) express proceduattachments; it a pure-belief is KR. KIF has been designed with an orientation towards knowledge as a non-executable specification as ecutable. Also, much or more than towards knowledge as exthe KIF effort has focused more on a highly inclusively expressive representation than thing the XML aspect of our approach This for rules to be: declarative is some- Ordinary Logic Programs [23], inhially we will leave "declarative" implicit.) KR, i.e., it lacks procedural attach- (Henceforth, a "pure-belief" is ments. Each Here, OLP rule in an <- Ao n > m Ai > has the form: /\ . . h . Am and each A, 0, ~^m+l A /\ A ~An. ... Aq a logical atom. is called is head (i.e., consequent) of the rule; the rest is called body (i.e., antecedent) of the rule. If the body is empty, the may <— and is A be omitted. ~ a fact. ground empty body rule with the the called is stands for the negation-as-failure operator symbol, read in English as "fail". Intuitively, not believed to be true, is i.e., ~p means that p's truth value that p either is false or unknown. on ease of develop- ing translators in and out of that representation (this Ordinary Logic Programs expressively restricted to the predicate-acyclic case (defined fundamental knowl- cannot (conveniently) express it KR Step: (OLP), with the well-founded semantics (WFS) ost logical non-monotonicity, including negation-as-failure, de- ral First simply conflicts, rather than -ip. begin defining our approach by choosing the fundamen- below). KIF can express form p versus conflicts of the Example 2 might be E.g., the first rule in written as: order Modi ficationNotice{'?Order, day sli) improves upon). pre ferredCustomerO f {? Buyer ISeller) <— , A purchaseOrderClOrder, ? Buyer, ? Seller) our In none of the above-listed previous approaches \ievv. to representing business rules, proach that we are aware of requirements we of, satisfactorily listed above Here, the prefix "?" indicates a logical variable. Ordinary LP's have been well-studied, and have a large nor any other previous ap- meets the whole set (in bold-face). In particular, lit- erature (reviewed, for example, in [I]). For several broad but restricted expressive cases, their (declarative) semantics is un- the widely-implemented approaches above lack sufficiently controversial: e.g., for the predicate-acyclic, stratified, locally declarative semantics; KIF, though declarative, lacks logical stratified, non-monotonicity. increasing expressive generality. However, KIF's declarative approach does, however, inspire us velop our own to de- and weakly cursion" here 4 A New Courteous Logic Programs + The approach — in to is choose Ordinary Logic Programs (OLP) the declarative sense Prolog — cretely in XML for tionally efficient, ] provides a helpful review), not plus to embody this KR con- Logic programs are noton ly relatively ut also practical, relatively computa- and widely deployed. KR CLP formalism to be Courteous Logic Programs expressively extends Ordinary Logic Programs to include prioritized conflict handling, computational tractability. CLP is a that there is a cyclic (path while maintaining previous KR [10] which "Ordinary" logic programs are also sometimes known as "general" (e.g., in [1]) or "normal" logic programs, or as (the declarative version of) "pure Prolog". of of syntactic) more generally, among the ground atoms) through rules. More precisely, a logic program S's predicate dependency graph PDGs is defined as follows. The vertices of the graph are the predicates that appear in S. rule r in acyclic" £ is {p,q) with means p that a (directed) (or, edge in PDGs iff there is a head and q in its body. "Predicatethere are no cycles in the predicate depen- in its dency graph. "Stratified" (in its various flavors) means cycles of a restricted kind are allowed. The well-founded semantics expressively extend the approach's declarative fun- damental (CLP). 1 KR, purposes of communication between the ' powerful expressively,b We ([ as a fundamental contracting agents. XML series of recursion with negation-as-failure. "Re- means dependency among the predicates Declarative Approach to Rules: form a OLP's have prob- lematic semantics for the unrestricted case, due essentially to the interaction declarative approach. stratified cases; these is probably the currently most popular semantics for the unrestricted case, and vorite. set is our fa- With WFS, the unrestricted case always has a single of conclusions, and strictions (e.g., Our approach business rules is tractable under commonly-met re- VBD defined below). for an initial practically-oriented KR stricted cases that is, however, to keep have uncontroversial research community) semantics — LP-based to expressively re- (i.e., consensus in the starting with predicate- Compared acyclic. uncontroversial cases, the unre- to these WFS) more complex computationally and, perhaps even more importantly, is more difficult in terms of software engineering, lireq uires more complicated stricted case (e.g., with algorithms and is and with relatively low computa- atively simple algorithm tional cost. WFS) (with entails a set consists of a set of premise rules, and of (primitive) conclusions. In a predicate-acyclic OLP, each conclusion has the form ofa ground atom. Intuitively, each conclusion atom is believed to be true, and every other (i.e., non-conclusion) ground atom is not believed to be (recall we Next, 1): ~ discuss the advantages of OLP OLP's (with WFS). has a fully declarative semantics that (Adv use- is OLP 2): in- cludes negation-as-failure and thus supports basic logical (Adv non-monotonicity. sive power, yet sively. (Adv is 4): OLP 3): and relatively simple OLP, unlike has considerable expresis not overkill expres- met expressive restrictions, e.g., rule-set execution — polynomial-time. Here, it is in the non-/^ero arity (a.k.a. VBD, say that an LP is in is Daialog co-NP-hard under the among many commercially has a it VBD restriction. is — and thus (Adv 5): We widely shared important rule-based systems as Prolog is the most obvious family of such systems. Relational databases are another such family; many SQL view algebra operations) are in effect definitions (and relational OLP rules. 0PS5-heritage production rule systems are less closely related because of of procedural attachments, but insofar their extensive use commonly do their semantics pure-belief predicate-acyclic inferencis closely related to forward-directed OLP's. Event-condition-action rules are somewhat similar this adding the capability to conveniently ex- in regard to a simple form of production rules. Other sys- tems sharing the semantics include many expert/knowledgebased systems and intelligent agent building tools; many of these implement forward-directed predicate-acyclic OLP's. Predicate-acyclic tational tractability (e.g., OLP KR a previous is semantics thus reflects a consensus in community that goes beyond the logic programming community. (Adv 6); Predicate-acyclic OLP's are, in effect, widely implemented and deployed, including in Prolog's and SQL relational databases, but also beyond them. the rule representation [10] under the VBD compu- which we have here further expres- sively generalized, notably to handle pairw'ise mutual exclu- -> sus ->p. (Here, CLP is a predicate /p having anty argument corresponds fc -I- 1, where inUiitively the (fe to the resultof applying the flinction. -|- l)"" p ver- -p stands for classical negation. Intuitively, believed to be definitely false.) can be tractably compiled to OLP. Indeed, we have implemented such a courteous compiler [II] [13] The compiler enables modularity in [12]. software engineering and LP ex- pressive capability can be added modularly to an Ordinary LP eases implementation and deployment: the Courteous pilation's computational often Com- simply by adding a pre-processor. rule engine/system complexity cubic, worst-case, but is closer to linear. is stead, here we we do CLP not have space to give formalism or will give an details, see [12] its full details about courteous compiler. In- overview and some examples. For and the forthcoming extended version of this paper. CLP handles conflicts between rules ordered prioritization information that is using partially- naturally available based on relative specificity, recency, and authority. Rules are subject to override by higher-priority conflicting rules. example, some rules may be For overridden by other rules that are special-case exceptions, more-recent updates, or from higherauthority sources. Courteous LP's ing, facilitate specifying sets of rules by merg- updating and accumulating, in a style closer (than Ordi- nary LP's or than classical logic/KIF) to natural language descriptions. The expressive extension provided by CLP valuable especially because is thus greatly facilitates incremental to explicitly modwhen updating or merging. In terms of the representation requirements we gave in section 3, this en- specification, ify it by often eliminating the need previous rules rule ables significantly greater modularity, locality,ea se of modification.e xpressive convenience, In CLP, labels: override s{rulel, rule2) means priority than rule2. will and conceptual naturalness. priorities are represented via a fact win the If that rulel and rule2 comparing rule rulel has higher conflict, then rulel conflict. CLP rule differs from an OLP rule in two may have an optional rule label, used as a Syntactically, a ways. First, it handle for specifying prioritization. Second, each rule usually straightforward to representationally refomiulate a rule-set so as to replace a logical flinction / having arity fc > by "It is CLP restriction). sion conflicts, rather than simply conflicts of the form In this paper, and restriction^) an expressive subset of their behavior. ing, WFS) by (with the generalized ''VBD" when just Courteous LP's (CLP) expressively extends Ordinary LP's i.e., logical variables appearing in each rule. observe predicate-acyclic OLP's semantics as they of developers (not are familiar with them. Programs worst-case has no logical fijnctions of it contrast, classical logic, e.g., first-order logic KIF, — inferencing can be computed ground, or (b) bounded number of By OLP we compuUnder commonly first-order-logic/KIF,is tationally tractable in the following sense. either (a) a large population is who KR Extension to Courteous Logic 4.2 means p above). and well-understood theoretically. ful There press prioritized conflict handling, while maintaining An OLP (.\dv 7): researchers) not widely deployed. The predicate-acyclic is expressive restnction can be checked syntactically with a rel- true (Adv may be classically negated. specialca se of CLP. An OLP mention classical negation. Syntactically, OLP rule lacks a label is literal simply a and does not A CLP rule has the fomi: <- Lo {lab) m > Here, n sical literal an atom. and The The label . is The . A ~L„. ... -i.4, or -4 English as "not", lab A clas- where .4 is the rule's label. is optional. If omitted, the label is not required to be unique within the scope of the label is treated as a above have may have rules all the tion is CLP entails a a ground (b) (c) between p and implicit mutual exclusion In the An conflict. ± order Modi ficationNotice{'?Order,?X) A <— e CLP {IX ^lY). also op- mutex 's specify the unconditional mutex has the syntactic form- ± is a classical Semantically, each such literal. mutual exclusion specified by a mutex is L2 enforced: Li and instantiation). These mu- tex's are particularly useful for specifying that at most one of are never both concluded (for a set of alternatives is to any be permitted. E.g., in Example 1 , it is straightforward to specify via a mutex that the refund percent- age must be at Example it 2, the lead time most one of the values {90% is , 100%}. at E.g., in example while handling conflict appropriately most one of the values {2 days, 14 Example 3, it is straightforward to section to use a more Semantically, the prioritized conflict handling opposing candidates. Opposition Each mutex's. is rule r ?Z I (?y 7^?Z). Li and ^2- E.g., giveDiscount[1Cust, lY Percent) A giveDiscount{1Cust, ?Z Percent) (lY Percent ^?ZPercent). This conditional mutex enables one to specify with a single mute.x statement (rather than with three or more unconditional mutex's) that for a given customer ICust there must be at most one value concluded for the discount percentage. tively in ± <— I The enforcement of set classical negation can be viewed as a oi implicit unconditional mutex's, one for each predicate CLP is among in label. In general, there i.e., p is the set of which i.e., is label, may for if there a candidate for an opposing c, then c an unrefuted candidate for p. concluded. However, which be multiple a team for p. If and only (i.e., no unrefuted candidates fiited satisfied, q) that has higher priority than candidate futed. Suppose there i.e., by specified is head p. This candidate has an associated an opposing candidate d are in candidate c for r's (appropriately instan- simply that rule r's literal are logical variables that appear respec- is whose body is Li A L2 is (recall andea se of modification defined by a process of prioritized argumentation candidates for a given p, and This 3). syntactic form: ^ more and underscores the advantage the discussion of modularity general form of mutex: a conditional mutex, which has the TV modifying the that prevent of the prioritized conflict handling expressive feature tiated) more convenient sometimes 1 regard to priorities add additional such interaction conditions. typical of conflicting rule-sets most one of the values {0%, 5%, 10%}. where in requires Moreover, adding a new rule requires modifying the other rules to "fires", generates a expressively — add extra "interaction" conditions specify via 3 mutex's that the discount percentage must be at It is LP directly as an Ordinary and guaranteeing consistency E.g., in straightforward to specify via 3 mutex 's that must be days, 30 days}. this than one rule applying to a given purchase order situation. Li A L2. t- — I To represent rules to where each Lj A order ModijicationNotice{10rder, lY) of pairwise mutual exclusion (mutex) statements, along with the rules. These '^Seller) overrides{c,a). -ip. newly generalized version of CLP,th tionally includes a set scope of any as preferredCustomerOfC? Buyer,? Seller) A order ModificationType{? Order, reduce) A orderltemi sInBacklogilOrder) A purchaseOrder{? Order, 1 Buyer, ISeller). <— can be viewed as the enforcing of an (classical literal) p. This CLP '? Classical nega- -^p are never both concluded, for p and enforced: CLP) in purchaseOrder{'!Order, Buyer, ? Seller). order Modi ficationNotice{?Order, days30) (— minor Part{? Order) A purchaseOrder{?Order, ? Buyer, ?Seller). or derModificationNotice{1 Order, days2) of (primitive) conclusions set Lead Time, preferredCustomerOf{? Buyer, <— the ground instances of classical literal. . order Modi ficationNotice{?Order, dayslA) (a) program. is , . 2 can be straightforwardly represented in to other predicate and function symbols appearing in the logic Semantically, a . follows: treated as part of the language of the logic program, similarly each of which , Example overrides and the labels are label lab. . 4 (Ordering same la0-ary function symbol. The label two i.e., . . arity is Example said to be empty. is is Q(?X1, IXni) A ^g(?Xl, ?Xm). m. This is called a classical mutex. <- where Q's a classical literal. is of the t'onn preserved during instantiation; the rule 1 stands for the classical negation operator symin each have the form that . and each I, 0, overall logic program; bel. Q, A Lm A A ~Lm+i A a Ibniiula read is label > is -> bol, Li is re- If there any opposer of p, then p wins, it may be that there is an unre- candidate for an opposer of p; in this case, the opposing unrefuted candidates skeptically defeat each other. The conflict its cannot be resolved by the specified priority; neither opposer is Another way locale is p nor concluded. to a set of view /i > thisis as follows. 2 ground classical pose each other,su ch that at An opposition- literals that most one of those literals mitted (by the specified mutex's) to be concluded. is opper- In each opposition-locale, if the maximal-priority candidates are same for the The literal, definition of restrictions, CLP then that CLP forcing additional expressive which we do not have space always produces the mutex's. all some includes to detail here. a consistent set CLP all wins. literal of conclusions, en- also has several other attractive well-beha\ ior properties, including about merging and about natural belun ior of prioritization; however, we do not have space here to detail these. The courteous compiler "adorning" predicates tra represents the priori- effect in OLP. tized argumentation process in It some introduces to represent the ex- intennediate stages of argumentation: candidates, unrefuted candidates, skepti- The compiler makes cal defeat, etc.. unresolved conflict, e.g., to raise it simple to detect an an alarm about in either it fonvard or backward reasoning. From the tractability of courteous compilation, directly that tion tractable. is complexity number of Note KIF It has the same worst-case time and space OLP as: inferencing where the bound v on variables per rule has been increased to w that CLP follows it VBD restric- Courteous LP inferencing under the -I- <?xml version="l 0"?> <clp> <erule rulelabel="a"> <head> <cliteral predicate= . "orderModi£icationNotice"> <variable name= "Order" /> < function name="daysl4 "/> </cliteral> </head> <body> <and> <fcliteral predicate= "preferredCustomerOf " > <variable name= "Buyer"/ <variable name="Seller"/> </f cliteral> <fcliteral predicate= "purchaseOrder" <variable name="Order"/> <variable name = "Buyer"/ <variable name= "Seller" /> </fcliteral> </and> </body> </erule> the 2. [rest of rules & mutex's skipped] </clp> overlaps syntactically and semantically with for a broad case. CLP without negation-as-failure, with- out labels (or ignoring labels), and without conflict, tactically a restricted (essentially ,cl ausal) case logic (FOL)/KIF. Semantically, such plete when compared to FOL/KIF, CLP is of is Figure syn- conclu- Business Rules XML a we second aspect beyond the funda- the rule representation concretely as may BRML to a subset also BRML inherits the declar- of CLP. ative semantics OLP be employing. is the first a XML embodiment of CLP of KIF, as described above, also an XML I DTD is in draft form; updates to the (1) the the we do XML CommonRules not have space to give encoding. prototype For full full details, download package desee: (at BRML XML approach has several advantages. fits into the draft stan- and integrating with XML is translate, WWW-world parsing software engineer- easier to automatically parse, generate, edit, XML-world tools links) aspects of XML because there are standard forth ese tasks. The are also useful. For example, a rule some facilitates It XML developing/maintaining parsers (via standard hyper-text (i.e., set may via XML have URL's which point to documents describing that rule set's knowledge representation or authors or application context. Or it may have associated URL's which point associated to tools for processing that rule set, e.g., to execute analyze it, or validate ciated paper, The As compared to the usual plain ASCII text style of embodKIF or Prolog or most programming languages, ticularly useful for this this paper. willbe posted on iment cf classical literal. about it FIPA Agent Communication Language (ACL) applying the negation-as-failure operator outside/in-front of a In (esp. "orderingleadtime" there); forthcoming extended version of dard. ing. is contains the communication languages, including and embodiment of that subset of KIF to our knowledge, the first XML embodiment of (any fragment oO KIF. Figure shows the CLP from Example 4 encoded in BRML. Only the first rule of that Example is shown in detail, "cliteral" means "classical literal", "fcliteral" means a rule body literal, i.e., a literal formed by optionally tails 4. See [14] for how (declarative) — Example larger context of agent also expressively covers BRML number of examples (2) the tools), our knowledge. Since for the authors' websites. the XML embodiment of CLP. Called Business Rules Markup Language (BRML), this XML embodiment functions as an interlingua between heterogeneous rule representations/systems which different congive, for the first time, an tracting agents and current documents. Next, BRML, http://alphaworks.ibm.com), which and Markup Language Our approach includes mental KR.W e embody e., XML Data Type Definition (DTD) for BRML, explanation of it, XML Embodiment: XML,i. : sound but incom- in that its entailed sions are equivalent to a (conjunctive) set of ground literals. 4.3 1 first-order- tics URL may it it, edit it, (syntactically or semantically). Par- our nearer-term purposes is that an asso- point to documents describing the seman- and algorithms for translator services or components, as well as to translator tools and examples. Representing busi- ness rules in XML has a further advantage: it will comple- ment domain-specific ontologies XML. Many ill vocabularies) available (i.e., are e.vpected to be developed in the ne.\t XML e-commerce domains. The in from systems engines One in C. els (version by built exhaustive is by I), several ac- These rule implemented Smod- forward-direction: Simons, Patrik http //saturn hut: f i/html/st;af f /ilkka html. The other is backward-direction: XSB, by David Warren al, htitp / /www cs sunysb edu/~sbprolog. el : . . . : In addition, . we have implemented built ourselves in Java. sample translator to a sample translator to a WFS OLP predicate-acyclic third, . . Furthermore, inferencing engine we we have implemented a Work There are several other formalisms is to a BRML is as a free CommonRules on the Web in July http //alphaworks ibm.com. This proJava library that includes both the CLP and the . aspects of ourapp roach. In particular, it includes a courteous compiler and sample translators between summary,we believe our approach combining CLP and meets the whole set of requirements we gave in secany previous approach. Indeed, we believe our approach meets every one of those requirernents nificant degree, with one exception: the to a sig- ability to express pro- rules in a declarative KR for represent- ing executable specifications of contract agreements largely on their following is based advantages relative to other soft- ware specification approaches and programming languages. First, rules are at a relatively high level of abstraction, closer human understandability, especially by business domain experts who are typically non-programmers. Second, rules to are relatively easy to modify dynamically and by such non- ularity, current work, ther to Situated ral we (i.e., are expressively generalizing fur- Courteous LP's, so as attachments as well — in well-behavior to enable procedu- a semantically clean mutex's (besides implicit classical mutex's), and none has a compiler to OLP's. There are other, more expressively powerfiil approaches to and Prioritized Circumscription [19] [18] [7] [8] that es- handling imposes computationally intractable overhead [6]. appears fairly straightforward to extend our It so as to express in stages KIF. A full first-order logic work direction for future BRML, mally compatibly with work In other is to create a full DTD, maxi- that expresses full KIF. we have extended [21], BRML DTD and then our contract rule wards automatic configuration of auctions, including which ify of a contract are attributes Of course, there yetm ore is promise, and achieve work include: its to do fiilfill our approach's Further issuesfo meshing more closely with other r as- pects of contracts, e.g., transactions, payments, negotiation and communication protocols [5] [20], EDI, and utility/cost- of com- benefit; fleshing out the relationships to a variety mercially important rule representations/systems; representing constraints as in constraint satisfaction and Constraint Logic Programs; and representing delegation as secu- in rity/authorization policies [17]. An extended as a version of paper this IBM forthcoming http //www. research : . be will Research avail- Report (at ibra. com). Acknowledgements Situ- Michael Travers(wh ile at IBM T.J. Watson Research UMBC, while at IBM T.J. and Xiaocheng Luan (of son Research Center), contributed attachments for condition-testing ("sensing") and action- of the knowl- linl< to ultimate goals. nary LP's, hook beliefs to drive procedural APIs. Procedu- edge representation: via sensor and effector to spec- be the subject of ne- gotiation or bidding. ated LP's[9] [16] [15], another expressive extension of Ordi- ("effecting'') are specified as part to manner declaratively in a particular well-defined sense). performing (e.g., in prioriti- zation behavior and merging). In particular, none can express ter) ral mod- consistency, unique set of conclu- (e.g., and conceptual simplicity sions), tractability, able programmersIn these nation of useful expressive power, software-engineering fiiture cedural attachments. The usefulness of work None of explore this dimension of heterogeneity. representation approach with negotiation features oriented to- XML tion 3 better than regard to conflict handling direction in our current other fonnalisms to our knowledge has as attractive a combi- BRML and several other rule systems/languages. In in A (see [10] [II] for a review). alpha prototype called totype semantics tex's) but different flict : for prioritized LP's that have similar syntax to Courteous LP's (except for lacking mu- sentially can express mutex's, but in these the prioritized con- The implementation of our approach was released al CLP cyclicity/recursion restriction, e.g., to be stratified rather than [2] of 1999, are also expressively generalizing further to relax expressive restrictions such as on prioritized default reasoning such as Prioritized Default Logic ANSI-draft KIF (ASCII format). Discussion and Future 5 BRML we work, In current and (bidi- WFS OLP and Niemela and llkka to e.xisting others go that feasibility. previously link associates a predicate with an at- predicate-acyclic. interlingua proof of as two include inferencing .\ML the systems rule tual (EDI) and other have implemented sample translators rectionally) facilitates XML. that "talk" Each sensor or effector tached procedure.' few years, including approach also integration with Electronic Data Interchange e-commerce components We many more such ontologies exist already, and statements. tation of the 'Note CLP KR, BRML, that "link" here HTML hypertext link. CenWat- to the current implemen- and the associated translators. does not mean in the sense of an XML or Micliacl Travers' contribution (UMBC) bodiment. Miao Jin was especially XML emXML DTD. Programs (Preliminary Report). nary Logic to the contributed to the IBM report, nical Watson T.J. Tech- Research Center, Daniel Reeves and Michael Wellrnan (ofU. Michigan) con- http://www.research.ibni.eom/pcople/g/grosof/papers.html, tributed to the fomiulation of the overall context and motiva- July 1999. tion lor automated contract languages. Thanks to anonymous [13] References 1 1 Chitta Baral and Michael Gelfond. Logic [3] In Menlo Park, MIT Press. / CA Cambridge, / Report priorities in default Proceedings of the Twelfth National Conference on Artificial Intelligence (AAAI-94), pages 940- Press MA, 1994. [14] RC using XML and a Rule-based Content Language with an Agent Communication Language. In Proc. lJCAl-99 AAAl in Pro- Thomas Cooper and Nancy Wogrin. Rule-based Programming with OPS5. Morgan Kaufmann Publishers, San Francisco, CA, 1988. ISBN 0-9346 3-5 -6. 1 1 [15] Benjamin N. Grosof, David W. Levine, and Hoi Y. Chan. Flexible procedural attachments to situate reaWashington,D.C., [16] Nguyen, M. Sachs, H. Shaikh, The Coyote Project: Framework for Multi-party E-Commerce. In Proc. 7th Delos Workshop on Electronic Commerce. Lecture Notes in ComAsit Dan, D. Dias, T. puter Science. Vol. Georg Gottlob. logics. Complexity results for nonmonotonic resentation [8] Generalizing Prioritization. Conf on A Benjamin N. Grosof tions thesis, in NonComputer Science ings [19] J. Intl. merce. Research Report Minsky and to formal- Artificial Intelligence, In Proc. 18th A Mech- for Electronic ComCom- Victoria Ungureanu. for EstablishingPo Intl. licies Conf on May Distributed 1998. Daniel M. Reeves, Benjamin N. Grosof, man, and Hoi Prioritized conflict handling for Y. Chan. Toward MichaelW a Declarative for Negotiating Executable Contracts. In Proc. gramming: Workshop on Artificial Intelligence merce (AIEC-99). Compiling Prioritized Default Report RC IBM Benjamin N. Grosof Generalized Courteous in [23] A Courteous Compiler from Logic Programs To Ordi- UUman and Jennifer Widom. A Database Systems. Prentice-Hall, 1997. A. Van Gelder, K. Ross, and J. AAAI-99 Electronic [22] Jeffrey D. Research 21472. in Schlipf ell- Language logic programs. In Jan Maluszynski, editor, Logic Pro- Benjamin N. Grosof RC Computing circumscription. In ProceedConf on AI (IJCAI-85), 1985. puting Systems (ICDCS), FY2 [21] Benjamin N. Grosof IBM commonsense knowledge. of Intelligent Agents and Multi-Agent Technology 137, Blackpool, Lancashire, is McCarthy. Applications of circumscription anism Box In Proc. 12th Security Foundations Workshop, Joint [20] Naftaly H. Rules Into Ordinary Logic Programs. [12] on Information 28:89-116, 1986. Proceedings of the International Symposium (ILPS-97),Ml T Press, 1997. [II] IEEE Computer izing 9UN, UK. [10] Intelligence in In- ACM Conf. Joan Feigenbaum, and Benjamin N. Grosof [18] V. Lifschitz. Updating and Structure PhD Li, Research Perspective (Invited Talk). In Proc. 2nd P.O. Chan, logic-based knowledge representation foraut horiza- Conference and Exhibition on Practical Applica- (PAAM97J, Y. Auerbach. Reusable Ar- 21492. Benjamin N. Grosof Building Commercial Agents: An IBM S. Embedding Rule-Based 1999. Extended version In Dept., Stanford University, Oct. 1992. Intl. and Joshua tion with delegation (extended abstract). Principles of Knowledge Rep- and Reasoning (KR-91), 1991. Monotonic Theories. [9] Ninghui Intl. Intl. 1998), Intelligent Information Agents, 1995. Journal of Logic and Computation, 2:397-425, 2nd 7. 1513. Springer- Verlag, 1998. Benjamin N. Grosof Proc. 778,150 (July and Knowledge Management (CIKM-95) Workshop on 1992. [7] Parris, formation Agents. In Proc. [17] [6] P. chitecture for Duri. S. 5, USA Benjamin N. Grosof, David W. Levine, Hoi Colin and Research Workshop on Agent Communication Languages, 1999. W. F.Cloc ksin and C.S. Mellish. Programming R. King, IBM is 21473. soning systems. In U.S. Patent [5] abstract of Intelli- Benjamin N. Grosof and Yannis Labrou. An Approach to log. Springer- Verlag, 1981. [4] Priori- gent Systems Demonstration). In Proc. AAAI-99,\^ 99. Morgan Kaufmann. Extended version Gerhard Brewka. Reasoning about 945, . Research Report. DIPLOMAT: Compiling Benjamin N. Grosof E-Commerce Applications (extended programming Journal of Logic Pro- gramming. 19,20:73-148, 1994. logic. IBM tized Default Rules Into Ordinary Logic Programs, for and knowledge representation. [2] CommonRules documentation Revised version forthcoming as reviewers for editing suggestions. [ Included in released July 30, 1999 at http://alphaworks.ibm.com First Com- Course The well- founded semantics for general logic programs. Journal of ACM, 38(3):620-650, 1991. DEC mi Date Due 3 9080 02246 1328