ruleml: data model, language hierarchy, and transformations harold boley, dfki gmbh, visiting...

52
RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar Series Talk at the Faculty of Computer Science, University of New

Upload: ethen-gawne

Post on 14-Dec-2015

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

RuleML:Data Model, Language Hierarchy,

and Transformations

Harold Boley, DFKI GmbH,

Visiting Researcher at NRC

IIT e-Business, Fredericton

2001 Seminar Series Talk at theFaculty of Computer Science,University of New Brunswick,Fredericton, December 3rd, 2001

Page 2: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk2

Web-Based Business Rules:Merchant-Customer Exchange Scenario (I)

Merchant1 Merchantm

. . .

Customer

requestrules ondiscountsetc.

requestrules ondiscountsetc.

preselect m best merchants(e.g., using purchasing rules)

Page 3: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk3

Merchant1 Merchantm

. . .

Customer

publishrulebase1

publishrulebasem

compare, instantiate,and run rulebases

Web-Based Business Rules:Merchant-Customer Exchange Scenario (II)

translate tostandard format(e.g., RuleML)

Page 4: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk4

Merchanti

Customer

order fromMerchanti

select best deal(e.g., discount)

Web-Based Business Rules:Merchant-Customer Exchange Scenario

(III)

Page 5: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk5

Web-Based Business Rules:Formalize Natural Language in Horn Logic

Prolog-like formalization (with XML underpinnings):

''The discount for a customer buying a product is 5.0 percentif the customer is premium and the product is regular.''''The discount for a customer buying a product is 7.5 percentif the customer is premium and the product is luxury.''. . .

English Business Rules:

Page 6: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk6

Semantics andPragmatics (Implementation)

Original Web: Distributed development, usage and

maintenance of HTML-based informal documents

Semantic Web: Employ same infrastructure for

formal specifications or declarative programs

Which Logics/Languages?

Uniform semantic/pragmatic foundation potential:

– Description Logic: RDF Schema, DAML+OIL for taxonomies

– Horn Logic: Prolog, RuleML for axiomsfor ontologies

Page 7: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk7

Syntax

Syntactic underpinnings, however, will most likely come from

Extensible Markup Language (XML)

Fortunately, translators between Prolog and XML syntaxes can

be defined

Can also form basis for semantic/pragmatic technology

transfers between Prolog and XML

Current talk will exemplify this using XML syntax of

Rule Markup Language (RuleML), Version 0.8

Page 8: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk8

XML-Prolog Initiative RuleML The Rule Markup Initiative works towards W3C submission

representing its various participants from industry and academia

First goal has thus been to provide modular system of RuleML sublanguages based on XML and RDF (Resource Description Framework)

This led to development of novel XML-RDF-integrating Web data model

On its basis, RuleML initially defined with hierarchy of DTDs, gradually redefined with XML Schema

To facilitate rule exchange, XSLT-based translators between RuleML and other rule languages have been specified

Page 9: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk9

Main Structure of the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 10: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk10

Next in the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 11: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk11

XML Elements as Ground Structures: The Idea

Each element is a sequence <tag>. . .</tag>,i.e. some ordered content ''. . . '' enclosed bytag-'colored' start- and end-brackets

This content may consist of text or again of elements

XML documents consist of (nested) elements:

Prolog terms can represent XML elements

as variablefree or ground structures tag(. . .)

Page 12: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk12

XML Elements as Ground Structures:A Markup Problem

In XML can use a positional representation,

where a power formula consists of a base followed by

an exponent

The base and exponent can each be marked up as an

integer

Example: Mark up power formulas, in atyped manner, as integer basesraised to integer exponents

Page 13: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk13

XML Elements as Ground Structures: XML and Prolog Solutions

Thus, power formula 32 marked up asnested element:

<powform> <integer>3</integer> <integer>2</integer></powform>

powform(integer(3),integer(2))

In Prolog this corresponds to more compact ground structure (integers and lower-case words will be used as constants):

Page 14: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk14

XML Elements as Ground Structures: Underlying Trees

Graph-theoretically, yield a tree with left-to-right-ordered arcs and two kinds of nodes labeled by their types, here powform and integer, where oval nodes are XML-like (sub)elements or RDF-like resources while rectangular nodes are XML-like PCDATA or RDF-like literals, here 3 and 2:

powform

3 2

integer integer

In general, these simple XML elements and Prolog terms constitute two equivalent ways of linearizing left-to-right-ordered, node-labeled trees (with oval inner nodes and rectangular leaf nodes)

Page 15: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk15

XML Attributes as Ground Structures

A start-tag can be enhanced by n non-positional attribute-value pairs of the form ai=vi, where vi must be a string (XML's CDATA)

In general, every element thus has the form<tag a1=v1...an=vn>. . .</tag>

Besides elements, XML uses attributes:

However, this can be reduced to the attributeless form<tag>v1...vn. . .</tag>, where n attribute values become positionalized as first n subelements: Ground structure Treat XML elements, incl. attributes, as Prolog-like terms

Data model that captures XML attributes non-positionally,as a special case, will be developed next

Page 16: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk16

Next in the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 17: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk17

Unify XML and RDF

XML based on, possibly attributed, left-to-right ordered, node-labeled trees, reminiscent of parse (syntax) trees

RDF based on directed, arc-labeled (unordered) graphs with two kinds of nodes, resources and literals, the latter not allowing outgoing arcs

XML and RDF have different data models:

With the advent of the Semantic Web a unified data model would be advantageous

Page 18: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk18

Problem with Positional XML Markup

Our powform's binary-positional convention''First child is base, second child is exponent'' for 32 markup seems natural and easy to memorize

But without some kind of 'signature declaration'this markup could instead mean 23 according to a''First child is exponent, second child is base'' convention

Analogous conventions for N-ary operators (N >2) need to disambiguate a combinatorially exploding number of possible interpretations

Without extra information the positions of 'roles' (powform: base and exponent) of children cannot in general be determined from some such markup

Page 19: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk19

Solution with Non-Positional RDF Markup

In 'object-centered' modeling and 'feature'/'frame' logics the way out is representing powers and other operators in a non-positional manner, making them objects with explicitly indicated roles for their arguments

In Frame/Horn-logic-integrating F-Logic, developed for RDF in TRIPLE, our example could thus be represented as a fact:

powform [base -> 3 : integer;exponent -> 2 : integer].

Page 20: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk20

Non-Positional RuleML Solution

Paralleling this in RuleML, we complement XML 'type tags' by distinguished, RDF-like 'role tags'

Generalizing XML attributes, roles will allow values that themselves contain markup

In our example we thus use powform with _base and _exponent subelements, where the leading ''_'' distinguishes roles:

<powform> <_base><integer>3</integer></_base> <_exponent><integer>2</integer></_exponent></powform>

Page 21: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk21

Role Commutativity

There are two correctly prefixed powform-child permutations, which we regard as algebraically equivalent commutative markups:

<powform> <_base><integer>3</integer></_base> <_exponent><integer>2</integer></_exponent></powform>

<powform> <_exponent><integer>2</integer></_exponent> <_base><integer>3</integer></_base></powform>

=

Page 22: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk22

Graph Identity and Markup Equation

Graph-theoretically, our data model permits trees with unordered arcs labeled by their roles, herebase and exponent, and nodes as introduced earlier:

powform

3 2

integer integer

base exponent

Generally, for trees branching order of (explicitly labeled) arcsis immaterial and for markups equation holds:

=<type>. . .<_role1>...</_role1>. . .<_role2>...</_role2>. . .</type>

<type>. . .<_role2>...</_role2>. . .<_role1>...</_role1>. . .</type>

Page 23: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk23

Order-Labeled Combination

RDF-like role-prefixed and XML‘s positional children can be easily combined, obtaining our basic RDF-XML integration of Order-Labeled (OrdLab) Trees

Example: Combine markup of a power sequencea1,..., an with the marked up formula of its base a and highest exponent n (length)

For the sequence 3, 9 combined with the formula 32:

<powseqform> <rational>3</rational> <rational>9</rational> <_base><integer>3</integer></_base> <_exponent><integer>2</integer></_exponent></powseqform>

Page 24: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk24

OrdLab Tree

Graph-theoretically, positional children become left-to-right-ordered arcs, here targeting the rationals 3 and 9, while role children become labels on un-ordered arcs, here targeting the integers 3 and 2 (different arrows emphasize ordered vs. labeled arcs):

9

rational

powseqform

3

rational

3 2

integer integer

base exponent

Page 25: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk25

Next in the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 26: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk26

Prolog Structures in RuleML

While we earlier reduced XML elements to Prolog ground structures, we now generically encode Prolog‘s Herbrand terms as XML elements, using the RuleML data model

Representation of Herbrand terms (individual constants, logic variables, and structures) in RuleML XML requires, in essence, use ofind, var, and cterm elements, where the

occurrence of a structure or complex term distinguishes Prolog from Datalog

Page 27: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk27

A cterm Example Markup

Example: Prolog ground structureundersea-connection(britain,france)in RuleML becomes cterm element withrole (unordered) subelement _opc for the functor/constructor of type ctor and two sequential (ordered) subelements for its argument terms, here two individual constants of type ind:

<cterm> <_opc><ctor>undersea-connection</ctor></_opc> <ind>britain</ind> <ind>france</ind></cterm>

Page 28: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk28

Unification of cterm Example Trees

This RuleML cterm markup as an OrdLab tree (left):

francebritain

cterm

opc

ctorundersea-connection

ind ind

<cterm> <ind>britain</ind> <var>xyz</var> <_opc><ctor>undersea-connection</ctor></_opc></cterm>

xyzbritain

cterm

opc

ctorundersea-connection

varind

Unifying non-ground structure or OrdLab tree (right):

Page 29: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk29

Next in the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 30: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk30

Relation Applications in RuleML

A predicate or relation symbol will in RuleML be a rel element. The application of an _opr-role-embedded relation symbol to a sequence of terms is marked by an atom element in RuleML

Example: travel applicationtravel(john,channel-tunnel)to two individual constants will thus be:

<atom> <_opr><rel>travel</rel></_opr> <ind>john</ind> <ind>channel-tunnel</ind></atom>

Page 31: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk31

Prolog Facts in RuleML

Horn fact in RuleML is asserted as a fact element that possesses exactly one subelement -- the _head-role-embedded atom element

Example: travel fact (containing travel application)

travel(john,channel-tunnel). becomes:

<fact> <_head> <atom> <_opr><rel>travel</rel></_opr> <ind>john</ind> <ind>channel-tunnel</ind> </atom>

</_head></fact>

Tree structure?fact

Subtree

_head

XML

fact

head

Subtree

OrdLab

Page 32: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk32

Prolog Rules in RuleML: Source

Horn rule in RuleML is asserted as an imp elementthat has two subelements -- a _head-role atom element augmented (either to its right or left) by a _body-role atom or and element

Example: travel rule (Datalog)

travel(Someone,channel-tunnel) :- carry(eurostar,Someone).

rewritten in RuleML thus:

Page 33: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk33

Prolog Rules in RuleML: Markup

<imp> <_head> <atom> <_opr><rel>travel</rel></_opr> <var>someone</var> <ind>channel-tunnel</ind> </atom> </_head> <_body> <atom> <_opr><rel>carry</rel></_opr> <ind>eurostar</ind> <var>someone</var> </atom> </_body></imp>

Page 34: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk34

Prolog Rules in RuleML: Tree

Graph-theoretically, RuleML clauses are again OrdLab trees, as illustrated for this rule:

imp

travel someone

atom atom

head body

opr opr

rel

carrychannel-tunnel someoneeurostar

var varindind rel

Page 35: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk35

Next in the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 36: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk36

Prolog in RuleML DTD/Schema Hierarchy

urc-bin-data-ground-facturc-bin-data-ground-log

urc-bin-datalog

bin-datalogurc-datalog

ur-datalog

ur-hornlog

ur-equalog

hornlog

equalog

datalogur

Rooted DAG will be extended withbranches for further sublanguages

URL/URI-like‘ur’-objects

ruleml

RDF-like triples

ur-datalog =

join(ur,datalog)

Focus on 12 sublanguages of derivation rule modules:All except the 'UR' (URL/URI) group correspond to well-known rule systems, with formal semantics

Page 37: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk37

Modular Sublanguage Composition

Each node in above hierarchy, e.g. 'hornlog', is a DTD/Schema that defines syntax of this sublanguage: Knowledge bases can refer to most specific DTD/Schema to maximize interoperability

Non-leaf nodes are composed of the -- possibly modified -- node(s) reachable via outgoing link(s) below plus possibly some extra definition parts

Example: 'hornlog' is composed of a -- slightly modified -- 'datalog' plus complex terms; 'datalog' itself contains 'bin-datalog', etc.

Page 38: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk38

From DTD to XML Schema: rulebases

DTD line (XML in EBNF-like SGML subset):

<!ELEMENT rulebase ((imp | fact)*)>

Schema part (official way to define XML in XML):<xsd:schema xmlns:xsd="http://...w3.org...XMLSchema">

<xsd:element name="rulebase"> <xsd:complexType> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="imp" type="impType"/> <xsd:element name="fact" type="factType"/> </xsd:choice> </xsd:complexType> </xsd:element> . . .

Page 39: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk39

From DTD to XML Schema: implications

DTD line (permuted _head / _body sequences):<!ELEMENT imp ((_head, _body) | (_body, _head))>

Schema part (unordered xsd:all set): . . .

<xsd:complexType name="impType"> <xsd:all> <xsd:element name="_head" type="_headType" minOccurs="1" maxOccurs="1"/> <xsd:element name="_body" type="_bodyType" minOccurs="1" maxOccurs="1"/> </xsd:all> </xsd:complexType> . . .

Page 40: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk40

Extending Datalog to Full Prolog

Remaining essential lines of 'datalog' DTD:<!ELEMENT _head (atom)><!ELEMENT _body (atom | and)><!ELEMENT and (atom*)><!ELEMENT atom ((_opr, (ind | var)*) | ((ind | var)+, _opr))>

We are currently investigating for XML Schema version the issue of composition mechanisms better than conditional DTD parts, involving xsd:redefine

Extended atom plus cterm lines for 'hornlog' DTD:<!ELEMENT atom ((_opr, (ind | var)*) | ((ind | var)+, _opr))>

<!ELEMENT cterm ((_opc, (ind|var|cterm)*) | ((ind|var|cterm)+, _opc))>

| cterm | cterm

Page 41: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk41

Next in the Talk

XML elements and attributes shown to correspond to Prolog ground structures

RuleML data model presented and illustrated via Order-Labeled trees

Permits to generically represent Herbrand terms as RuleML XML elements

Horn clauses similarly represented as XML elements Prolog defined within the DTD/Schema Hierarchy of

RuleML sublanguages XSLT translators exemplified by bidirectional

RuleML-RFML transformer and HTML renderer

Page 42: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk42

HTML Rendering of Business Rules

Before our XML-to-XML roundtrip: RFML version, via XML-to-HTML stylesheet rfmlsp, will lead to font-and-color-coded HTML Prolog version, rendered in a browser (first line is sample rule):

Page 43: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk43

XSL Transformations from and to RuleML

Exemplary pair of 'inverse' translators ('stylesheets') exporting/importing markup between RuleML and RFML (Relational-Functional Markup Language),where only the logic part is needed for Prolog:

Export via ruleml2rfml.xsl:Stylesheet translates Hornlog RuleML rulebase to corresponding RFML program

Import via rfml2ruleml.xsl:Stylesheet translates a Hornlog RFML program to corresponding RuleML rulebase

Page 44: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk44

Bi-Transforming Discount Sample Rule''The discount for a customer buying a product is 5.0 percentif the customer is premium and the product is regular.''

<rulebase> <imp> <_head> <atom> <_opr><rel>discount</rel></_opr> <var>customer</var> <var>product</var> <ind>5.0 percent</ind> </atom> </_head> <_body> <and> <atom> <_opr><rel>premium</rel></_opr> <var>customer</var> </atom> <atom> <_opr><rel>regular</rel></_opr> <var>product</var> </atom> </and> </_body> </imp></rulebase>

<rfml> <hn>

<pattop> <con>discount</con> <var>customer</var> <var>product</var> <con>5.0 percent</con> </pattop>

<callop> <con>premium</con> <var>customer</var> </callop> <callop> <con>regular</con> <var>product</var> </callop>

</hn></rfml>

ruleml2rfml.xsl

rfml2ruleml.xsl

Page 45: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk45

Export from RuleML: Tree Rewriting (I)

rulebase

Subtree Subtree. . .

rfml

. . .

Subtree Subtree

What does this XML processing look like in XML?

Page 46: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk46

Export from RuleML: Implementation (I)

First XSLT rule ('template') matches document root ''/'' followed by rulebase element;it 'recursively' maps ('applies') all matching templates to all rulebase subelements and generates rfml element from result:

<!-- process rulebase and position fact/imp transformers --><xsl:template match="/rulebase"> <rfml> <xsl:apply-templates/> </rfml></xsl:template>

Page 47: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk47

Export from RuleML: Tree Rewriting (II)

fact

Subtree

_head

hn

Subtree

Page 48: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk48

Export from RuleML: Implementation (II)

Second template matches fact element, does apply-templates over its _head in mode pattop (for RFML's operator patterns),and generates hn element from result:

<!-- process fact, transforming it to hn clause without premises --><xsl:template match="fact"> <hn> <xsl:apply-templates select="_head" mode="pattop"/> </hn></xsl:template>

Page 49: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk49

Export from RuleML: Tree Rewriting (III)

atom

PCDATA

_opr

rel

Argterm Argterm. . .

pattop

PCDATA

con. . .

Argterm Argterm

atom

Argterm Argterm. . .

PCDATA

_opr

rel

Implementation details: ruleml2rfml.xsl

Page 50: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk52

Web Technology for Prolog

Prepared semantic-pragmatic XML-Prolog transfers

using XML syntax: http://www.dfki.de/ruleml

XML-RDF-integrating data model used as basis for

DTD/Schema definitions of Prolog on the Web

Started semantic-pragmatic transfers in direction

XML-to-Prolog by specifying (semantics-preserving)

XSLT-based translators RuleML RFML

It is now possible to build and exchange

Prolog knowledge bases over the Web

Page 51: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk53

Web Technology for General Use: DTDs and XSLT are Still Most Practical,XML Schema and XQuery are Promising Demonstrated practical use of W3C technologies

such as DTDs and XML Schema as well as XSLT On the other hand hinted at a few problems with

current version of XML Schema, hoping that more expressive version will be available in future

Functional and logic programmers may also have wondered whether XSLT-based translators could be specified more concisely in future version of XSLT

Perhaps XQuery can act as incentive towards formal semantics of XML queries and transformations

Page 52: RuleML: Data Model, Language Hierarchy, and Transformations Harold Boley, DFKI GmbH, Visiting Researcher at NRC IIT e-Business, Fredericton 2001 Seminar

UNB RuleML Talk54

Prolog Technology for the Web

Corresponding transfers in Prolog-to-XML direction

have already started with Mandarax, j-DREW, and

other RuleML engines based on Prolog technology

It may also be useful to implement (orthogonalized

versions of) XML Schema, XSLT, etc. in (RuleML

and) Prolog to explore limits of expressiveness that

can be realized formally and efficiently

Side-effect of this work could be translators between

XML syntax and more concise Prolog syntax for W3C

languages such as XML Schema and XSLT