From: Harold Boley ([email protected])
Date: 05/27/03
Hi JC Colleagues, continuing our Datalog and Hornlog rules presentation at http://home.attbi.com/~stabet/ruleml/essential/essentialruleml.html as well as today's discussion about rules syntax, I have further developed the merger of Prolog and F-Logic syntax from "The Rule Markup Language": http://link.springer-ny.com/link/service/series/0558/bibs/2543/25430005.htm http://www.dfki.uni-kl.de/~boley/ruleml-mht.pdf Best, Harold Rules ASCII Syntax: Ordered and Unordered Options ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Let us reconsider our Datalog example: discount(Customer,Product,"5.0 percent") :- premium(Customer), regular(Product). Note that this is a positional (ternary) discount relation, where you have to remember in queries that the first argument is the customer, the second is the product, and the third is the rebate obtained. This is in the spirit of XML's ordered children. Also note that the comma infix within n-ary relation applications for n>1 can be regarded as the order-imposing sequence operator (while for n=0 and n=1 the sequencing degenerates). Reliance on order can be avoided in the spirit of RDF, DL and F-Logic by introducing properties, attributes, or roles. For example, an F-Logic-style version of the above rule can be written as follows: discount(cust->Customer;prod->Product;rebate->"5.0 percent") :- premium(cust->Customer), regular(prod->Product). Note that in this object-centered ('object-oriented') modeling of relations the semicolon infix indicates an unordered set of n slots, each consisting of a 'role->filler' pair. Queries can now be posed without need for any order information (however, knowledge of the role names cust, prod, rebate is needed instead): Generalized (role) unification takes care for pairing up identical roles before recursively unifying their fillers (we don't go into the issue of implicit/explicit 'rest' variables here). The query discount(rebate->Amount;prod->"Honda";cust->"Peter Miller") thus succeeds if premium(cust->"Peter Miller") and regular(prod->"Honda") were stored as facts, binding Amount to "5.0 percent". However, for unary relations like premium and regular, as well as for some binary relations, the role (->) syntax may become cumbersome. So in OO RuleML (http://www.ruleml.org/indoo) we permit rules using both ordered and object-oriented relations as premises as well as conclusions. In the example, with an object-oriented discount relation and (degenerately) ordered premium and regular relations, we obtain the following rule: discount(cust->Customer;prod->Product;rebate->"5.0 percent") :- premium(Customer), regular(Product). Finally, suppose we start again with positional Datalog rules, but then want to add optional spatio-temporal coordinates. Instead of extending the argument sequences of all affected relations by further ordered arguments, it may be preferable to add these extra bits in the unordered, object-oriented way. Restricting the rule scope to the region of MA and the period of 2003/04, our example thus becomes: discount(Customer,Product,"5.0 percent";region->"MA";period->"2003/04") :- premium(Customer;period->"2003/04"), regular(Product). We assume that the 'ordered infix' (,) has precedence over the 'unordered infix' (;), so that the ordered sequence as a whole is connected with the "->" slots via a ";" (here, the one preceding the region role). The query discount("Peter Miller","Honda",Amount;period->When;region->Where) succeeds if premium("Peter Miller";period->"2003/04") and regular("Honda") were stored as facts, binding Amount to "5.0 percent", When to "2003/04", and Where to "MA". For Hornlog rules, complex terms are enriched by roles in the same fashion. In the example, the individual constant "5.0 percent" can be analyzed as the cterm percent[5.0], and the constant "2003/04" can be analyzed as either a positional cterm interval["2003","2004"] or again as an object-oriented cterm interval[start->"2003";end->"2004"]. Note that square brackets are preferable for cterms to clearly set them off from the parenthesized atoms. Consistently substituting these cterms for the constant occurrences in the above OO Datalog rule gives us one of the following OO Hornlog rules: discount(Customer,Product,percent[5.0]; region->"MA"; period->interval["2003","2004"]) :- premium(Customer;period->interval["2003","2004"]), regular(Product). discount(Customer,Product,percent[5.0]; region->"MA"; period->interval[start->"2003";end->"2004"]) :- premium(Customer;period->interval[start->"2003";end->"2004"]), regular(Product). These options are offered to accomodate various positional and object-oriented modeling styles. They can all be marked up in OO RuleML.
This archive was generated by hypermail 2.1.4 : 05/27/03 EST