The Rule Markup Initiative

Download Report

Transcript The Rule Markup Initiative

RuleML:

Markup von Regelwerken im Semantischen Web (Markup of Rule Systems in the Semantic Web)

Harold Boley, DFKI GmbH Online 2002, Düsseldorf, January 29 st , 2002

1

International 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 (

R

esource

D

escription

F

ramework)  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 RuleML Online 2002

2

Web-Based Business Rules: Merchant-Customer Exchange Scenario

(I)

Merchant 1 Merchant m

. . .

request rules on discounts etc.

Customer RuleML Online 2002 request rules on discounts etc.

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

3

Web-Based Business Rules: Merchant-Customer Exchange Scenario

(II)

Merchant 1 Merchant m publish rulebase 1

. . .

translate to standard format (e.g., RuleML) publish rulebase m compare, instantiate, and run rulebases Customer RuleML Online 2002

4

Web-Based Business Rules: Merchant-Customer Exchange Scenario

(III)

Merchant i order from Merchant i Customer RuleML Online 2002 select best deal (e.g., discount)

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

English Business Rules: ''The

discount percent

if the

customer

percent

if the

customer

for a

customer

is is

premium premium

buying a and the and the

product product product

is is

5.0 regular

is

luxury

.'' .'' Prolog-like formalization (with XML underpinnings):

5

RuleML Online 2002

Semantics and Pragmatics (Implementation)

Original Web:

Distributed development, usage and maintenance of HTML-based informal documents

6

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 ontologies for axioms RuleML Online 2002

Syntax

7

 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

RuleML Online 2002

8

Unify XML and RDF

XML and RDF have different data models:  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 With the advent of the Semantic Web a unified data model would be advantageous RuleML Online 2002

9

Problem with Positional XML Markup

    For marking up

3 2

, an XML element

powform

might be employed, with the positional convention

''First child is base, second child is exponent''

But without some kind of 'signature declaration' this markup could instead mean

2 3

according to a

''First child is exponent, second child is base''

convention Analogous conventions for

N

-ary operators ( number of possible interpretations

N

>2) need to disambiguate a combinatorially exploding ( Without extra information the positions of 'roles'

powform

: base and exponent) of children cannot in general be determined from some such markup RuleML Online 2002

Solution with Non-Positional RDF Markup

10

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].

RuleML Online 2002

Non-Positional RuleML Solution

Paralleling this in RuleML, we complement XML

'type tags'

by distinguished, RDF-like

'role tags' 11

Generalizing XML attributes, roles will allow values that themselves contain markup In our example we thus use

powform

and

_exponent

with

_base

subelements, where the leading ''

_

'' distinguishes roles:

<_base>3 <_exponent>2

RuleML Online 2002

12

Role Commutativity

There are two correctly prefixed

powform

-child permutations, which we regard as algebraically equivalent commutative markups:

<_base>3 <_exponent>2

=

<_exponent>2 <_base>3

RuleML Online 2002

Order-Labeled Combination

For the sequence

3, 9

combined with the formula

3 2

:

3 9 <_base>3 <_exponent>2 powseqform 14 rational

3

base

rational integer

9 RuleML Online 2002 3

exponent

2

integer

16

Relation Applications in RuleML

A predicate or

relation symbol

rel

element

. The

application

will in RuleML be a of an

_opr

-role embedded relation symbol to a sequence of terms is marked by an

atom

element

in RuleML Example:

travel

application

travel(john,channel-tunnel)

to two individual constants will thus be:

<_opr>travel john channel-tunnel

RuleML Online 2002

17

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 > <_opr>travel john channel-tunnel

RuleML Online 2002

Tree structure?

fact _head Subtree XML

fact

head

Subtree OrdLab

18

Derivation Rules in RuleML: Source

Horn rule in RuleML is asserted as an

imp

element

that 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: RuleML Online 2002

19

Derivation Rules in RuleML: Markup

<_head> <_opr>travel someone channel-tunnel <_body> <_opr>carry eurostar someone

RuleML Online 2002

20

Derivation Rules in RuleML: Tree

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

imp

head body

atom atom

opr

rel

travel

var

someone

ind

channel tunnel

opr

rel

carry

ind

eurostar

var

someone RuleML Online 2002

21

The RuleML DTD/Schema Hierarchy

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

ruleml

ur

URL/URI-like ‘ur’-objects

ur-equalog ur-hornlog

ur-datalog

urc-datalog equalog

Rooted DAG will be extended with branches for further sublanguages

hornlog

datalog

ur-datalog = join(ur,datalog)

bin-datalog urc-bin-datalog urc-bin-data-ground-log urc-bin-data-ground-fact RuleML Online 2002

RDF-like triples

Derivation Rules in UR-Datalog: Indexing

22 <_head> <_opr>travel someone channel-tunnel <_body> <_opr>carry eurostar someone

RuleML Online 2002

23

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.

RuleML Online 2002

From DTD to XML Schema:

rulebase

s

DTD line (XML in EBNF-like SGML subset): 24 Schema part (official way to define XML in XML):

. . .

RuleML Online 2002

From DTD to XML Schema:

imp

lications

25 DTD line (permuted _head / _body sequences): Schema part (unordered xsd:all set):

. . .

. . .

RuleML Online 2002

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):

27

RuleML Online 2002

28

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 RuleML Online 2002

29

Bi-Transforming Discount Sample Rule

''The

discount < percent

if the

>

customer

for a

customer

is

premium

buying a

product

and the

product

is

5.0

is

regular

.''

< imp > <_head> < atom > <_opr> discount customer product 5.0 percent <_body> < atom > <_opr> ruleml2rfml.xsl

rfml2ruleml.xsl

premium customer <_opr> regular product rulebase >

RuleML Online 2002

< hn > < pattop > customer product discount 5.0 percent < callop > premium customer < callop > regular product

Export from RuleML: Tree Rewriting (I)

rulebase . . .

Subtree Subtree

30

rfml . . .

Subtree Subtree

What does this XML processing look like in XML?

RuleML Online 2002

Export from RuleML: Implementation (I)

31

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:

RuleML Online 2002

32

Export from RuleML: Tree Rewriting (II)

fact _head Subtree hn Subtree RuleML Online 2002

33

Export from RuleML: Implementation (II)

Second template matches

fact apply-templates

over its element, does

_head

in

mode pattop

(for RFML's

op

erator

patt

erns), and generates

hn

element from result:

select="_head" mode="pattop" />

RuleML Online 2002

34

Export from RuleML: Tree Rewriting (III)

atom _opr Argterm . . .

Argterm rel PCDATA atom Argterm . . .

Argterm _opr rel PCDATA pattop con Argterm . . .

Argterm PCDATA RuleML Online 2002 Implementation details:

ruleml2rfml.xsl

Web Technology

for Prolog

37

 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

RuleML Online 2002

38

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 RuleML Online 2002

Prolog Technology

for the Web

39

 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 RuleML Online 2002