• Keine Ergebnisse gefunden

On the semantics and interpretation of rule based programs with static global variables

N/A
N/A
Protected

Academic year: 2022

Aktie "On the semantics and interpretation of rule based programs with static global variables"

Copied!
14
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Keywords Abstract.

1 Introduction

Based Programs with Static Global Variables

ManfredSchmidt-Schau

:knowledgerepresentation,semantics,rule-basedprogram,pro duction

rules,exp ertsystems,defaultrules,parallelexecution,three-valuedlogic

Pro ductionrulebased programminghasb een inusesincetheearlyexp ert sys-

tems([BFKM85,BS84])andcanb eseenasanforerunnerofthedeclarativepro-

grammingstyle.Nowadays,knowledgebasedsystemsarebasedonanintegration

oftwoormoreprogrammingstyles,likeintegrationoflogicandfunctionalpro-

gramming,which p ermits to use features of dierent programmingstyles, but

maylo osethedeclarativenessofrules.Thegoalof thispap eristodemonstrate

that the pro ductionrule style of programmingremains usefuland p owerful, if Fachb ereichInformatik

JohannWolfgangGo ethe-Universi tat

Postfach111932

D-60054Frankfurt

Germany

e-mail:schaus s@in formatik .uni -frankfurt.de

A rule based program is a set of pro ductio n rules of the

form\whenconditionthenassignment".Weprop osetousearestricted

form of rules as a rule-based programming paradigm. We sacrice the

p ossibil i ty ofexplici tely assignin g newvalues toavariable.Thegain is

thatthenalresultofrunningaprogramisindep endentfromtheorder

of rule execution and that rule execution can b e paralleli zed without

restrictions. Afurthergainisthatrules arereallydeclarative,andthus

lo cal changes have amorepredictabl e eectthan in general rulebased

programs.

Weprop oseasanaturalsemanticsasemi-lattice orderedbyinformation

content. Using this semantics we are able to show that rules can b e

indep endently executed, even in parallel in adistributed environment,

if only minor restriction s are satised. This semantics also gives clear

hints on the implementatio n of default rules that use meta-predicates

like unknown?intheirpreconditi on.

Thereareseveralinterestingsp eciali sati ons.Oneisthattheinformation

contentofavariablemayonlyb e\unknown"or\completelyknown",i.e.

thetruthvaluesofathree-valuedlogic.Anothersp eciali zatio nisinterval

arithmetic onnumb ers. Thismo dels thesituation wherethevalue ofa

variableisknowntob ewithin someinterval.

(2)

2 Syntax of Mini-RBL

j

j j j j j

j

j j j

j j j j

j

j j

j0j3j

j

< > < >

< > < >

< > < > < >< >< >

< > < >

< > < >

< >

< > < >< >< >

< >

< > < > < >< >< >

< >

< > =

< > < > < > < > < >

to viewglobalvariables ascontaining knowledge ab outanentity intheworld,

andtheprogramexecutiongeneratesmoreknowledgeusingtheavailableknowl-

edge. This excludes for examplethe usageof counters or variables that gather

evidence bymanipulatingaglobalvariable.

Dropping general assignmentsapp ears to b e rather restrictive, since most

programming techniques used in rule based systems cannot b e used, as they

dep end onmutableglobalvariablesorontheexecutionorderofrules.However,

thereareseveral advantages.Therule-basedprogramisindep endentoftheow

ofcontrol.Ononehandthisp ermitslo calvericationofthesoundness ofrules,

on the other hand the compiler can rearrange the rule execution in order to

improveeciency ortoexecute therulesconcurrently.

Therearetwotechniquestocomputevalues,oneisevaluationofexpressions,

likeinapplicativeprogramming,andtheotheristogatherinformationinglobal

variables by overwriting unknown variables with their value, when this value

b ecomes known. Hence there is an implicitway of mo difyingglobalvariables.

A naturalgeneralizationis an intervalarithmetic.The idea is that aprogram

computesconstraintsonthevaluesofglobalvariables.Thisisapracticallyuseful

extension,sinceingeneraltheinputisnotanexactvalue,forexamplemeasured

valuesareingeneralexactwithinsomegivenerror range.

Asuccessful instance oftheprogrammingparadigmisthesystemPro.M.D.

([PT88], [TP90]) that is in everyday use in a clinical lab oratory. Pro.M.D.is

arule based exp ert systemshell that issuccess fullyused with severaldierent

knowledgebasesforroutinediagnosisandclinicalchemistryanalyses.Itisimple-

mentedinProlog,andcompilesrulesintoPrologpredicates.Thispap erjusties

andclariestheprogrammingparadigmthatwasusedinPro.M.D.Furthermore

asemanticallycorrectusageandinterpretation ofdefaultrulesisdevelop ed.

Weintro duceasmallrule-based languageMini-RBL,whichcanalsob eseen as

a subset of the Pro.M.D-language.Every program consists of a set of rules of

theform"IF cond THEN action ".

cond ::= b-expr

b-expr ::=NOT b-expr b-expr b-op b-expr

F T UNKNOWN c-expr b-var

(known? b-expr ) (known? n-expr )

b-op ::=AND OR EQUIV IMPL

c-expr ::= n-expr n-cmp n-expr

n-cmp ::=GT GE EQ LE LT

n-expr ::= numb ers n-expr n-op n-expr

UNKNOWN n-var

n-op ::=+

action ::= b-var := b-expr n-var := n-expr

(3)

i

1 2

2

Denition3.1

x y y x

D

unk now n D

a;b D c a c b c

d a;b d c

a;b l ub a;b

a a

a a a i

3 Semantics of production rules with static global

variables

rule-based Mini-RBL program

An admissable semantic domain is a partially ordered set,

such that

i.) Thereisaleastelement,called in .

ii.) For ,ifthereissome with and ,then thereisaunique

leastelement with .Thiselement iscalledleastupper boundof

(denoted ).

iii.) Furthermore for every increasing chain of elements, there

existsaleastupper bound with forall .

numb ers.For ease of notation, we write \x := t" for rules of the form \IF T

THENx:=t".

Syntactically,UNKNOWNis aconstant. Its meaning is that thevalue ex-

ists,but is notknown.The values ofthe Bo oleanand arithmeticfunctions for

unknown argumentscan b edetermined inastraightforwardway.For Bo olean

op erators,thisgivestruthtables usingthreetruthvalues.Theusualb ehaviour

ofarithmeticop eratorsis thattheyevaluatetoUNKNOWN,ifat leastonear-

gumentisUNKNOWN(cf.section 6).Thesyntaximpliesthat thereis anite

setofglobalvariables.Dep endingonthepurp ose someofthemmayb eviewed

asinput,outputorauxiliary.

A is a set of rules that corresp onds to the

syntax ab ove.Theexecution ofarulebased programconsistsof ringrules, if

theirconditionistrue,untilruleringdo esnotmo difyglobalvariablesanymore.

Iftheconditionevaluatestounknownorfalse,thentheruledo es notre.This

executionof Mini-RBLprograms is guided by theprinciplethat the execution

sequence ofrulesshouldnotinuencetheresult.Aconsequence isthat explicit

assignmentto variablesis forbidden.Variableshaving thevalueunknown may

b e overwritten with a value, an assignment of the samevalue to avariable is

alsop ermitted.Ifavariableisalreadyassigned avalue(except unknown), and

a further assignment tries to assign a dierent value,then the program stops

witherror\conictingfacts". Thiserroris seenasaprogrammingerror that is

dynamicallydetected.

n order to provide a denotationalsemantics [Sto81] for pro duction rules with

staticglobalvariables(andthusalsoforMini-RBLprograms),wemo delthein-

formationcontentofvariables.Therefore,weuseanupp er,completesemilattice

asasemanticdomain. meansthat containsmoreinformatinthan .

Thereissomerelatedworkintheareaofasynchronousandparallelpro cesses

(see [Gla90] and [GK91]), where anenvironmentusing theprinciple of single-

assignmentvariablesisinvestigated.However,thisworkdo esnotconsiderthree-

valuedlogicnoralatticeofinformationcontent.

( )

...

(4)

>

>

>

> >

>

> >

> > >

3

>

> 3

>

0

3

1 1

1 2

0

0

0

0

0 0 1 2 0 0

1 2

1

0

+1 Denition3.2

Denition3.3

Lemma 3.4

n

n n

i i

n

n

n

n

n n

n

n n

i

n n n

n

n

n

i

i i i

i

i i

i

k

i i m m

f 2 j g f 2 j g f g

>

>

! > > )

!

2

!

2

! 2

2 2 2

2

!

2

2

2

x Dx<fal se x Dx<tr ue unk now n

D

D

D v ; ;v w ; ;w

v w i

D

D

D ' D

D ' v w 'v 'w

' D D v 'v

v D

D 8

' D D 8

' ;' ; ' D 8

8 D D w D ;

W w W w W 'w W

' 8 8 w

D 8 D

D 8 w

w D c ;c ;c ; c w

' ;' ; ' 8

c 'c i ; ;

c W

l ub8 w

c

W c

w W c w 'w

c c 'c

imalelements, and .

Let beanadmissablesemanticdomain.Afunction

is , i and . A function

is ,i itismonotonic and for

all .

Let be an admissable semantic domain. Let be a set of

functions .A sequenceofapplicationsof isasequence

with such that every function in occurs innitely often in

this sequence.

Let be an admissable semantic domain and let

be a nite set of strongly monotonic functions. Let W := for

some . Consider a chain with that isderived

with a fair sequence of applications of functions , such that

for .

Then the limitof isa leastupper bound of and viceversa.

Thislimitelementisalso denoted as

Proof.

= =

canb edescrib edasacompleteupp ersemilatticethatcontainsthedomain

of athree valuedlogic(see [Hah93],[Urq86]).Furthermorethere isno greatest

element in . A motivation forthe omissionof agreatest element is that the

domain of b o olean values could only b e extended if some algebraic rules are

sacriced.

Theordering on is the pro ductordering ( ... ) ( ... ) i

for all . This pro duct ordering satisesconditions i)-iii)of Denition

3.1.Inorderto avoiddealingwithpartialfunctions,weextend thedomain

to b e a latticebya topelement (which could b e interpreted as inconsistent

knowledge)that isgreater thanallother elements.Thecorresp onding setwith

the extended ordering is denoted by( ) . Elementsthat arenot equalto

are calledprop er elements.

:( )

( ) monotonic =

: ( ) ( ) strongly monotonic

( )

Wedonotenforcethatfunctionsarecontinuousinthesenseoflatticetheory.

:( ) ( ) fair

...

Let : ( ) ( ) b e anite set of functions.For ( ) we

inductivelydene aset with , andif ,then ( ) for all

.Weabbreviate thissetas ( ).

: ( )

( ) ( )

( ) ... =

...

= =1 2 ...

( ( ))

Note that by the strong monotonicity criterion, ( ) is an increasing

chain.

1.) Firstwe showthatforevery elementin thereissomegreater element

inthechain.Wemakeinductiononthenumb erofapplications.Assumethat

forsome ,we have anelement . Nowconsider . Since the

chain isfair,there isan indexminthechain( ),such that = ,

(5)

2

0 1 0

1

1 1

0 0

0

0

0

0

>

>

> >

>

0

3

>

>

3 2

! f g !

2

6

2

>

2 2

2

Denition3.5

Corollary3.6

m k m m m

i i

i

n

i

i i

n

i

n n

n n

i

i n

i

n

n

new old

W

c

c W

D W

c W

c W c W

D

IFTHENcond;t i n

cond D unk now n;tr ue;fal se t D D

w v ; ; ;v D

IFTHENcond;t w

l ub w ; v ; ;v ;t w ; ;v if condw tr ue

w if condw tr ue

8 IFTHENcond;t

8 ' 8

w W 8 w

W w

W P l ubW

P

w D 8 ' 8

'w w

8 w D

w 8 8 w

v t

v t

v l ub v ;t

' w 'w

We dene on .

The operator for accepts two functions as

arguments: , and . For

,then

A isaset offunctions of the form .

a.) A D-program is ,iall arestronglymonotonic.

b.) Let bethe input tothe programand let .Then thereare two

cases

i.) hasonly asupperbound.Thentheprogramis on .

ii.) hasaproperupperbound.Thentheoutputof is .Wedenote

thisoutput as .

c.) An element isax-pointforthe D-program ,iforall ,

wehave .

d.) A D-program on the input ,i thereis some x-

point for inthe set .

The result of an admissable D-program is independent of the

sequence,inwhichrulesaretriedandred,aslongasthesequenceisafairone.

This holds for the three possible types of behaviour: Termination with success,

termination with failure, and non-termination. In the case of non-termination

the programapproximatesthe result.

have shownthat every elementin isdominated bysomeelementof the

chain ( ).

2.) Theconverseis trivial,since everyelementin isalsoin .

3.) Note that due to the denition of ( ) , the set alwayshas an upp er

b ound. The limitof the chain is also a least upp er b ound of , since

and( )dominateseveryelementof .

D-programs ( )

( ) 1

:( ) :( )

=( ... ... ) ( )

( )( )=

( ( ... ( ) ... )) ( )=

( )=

D-program ( )

admissable

=

contradictory

( )

[[ ]]

( )

( )=

terminates ( )

( )

Thisdenitioninterprets rulesas follows.Iftheconditionoftheruleissat-

ised, then the assignment := inthe assignmentpart do es notreplace the

valueofthevariable bythevalueof ,butcomputestheleastupp er b oundof

theoldandnewvalue,i.e., := ( ).Thisconformswiththeintuition

of information gathering.The interesting p ointis that on therighthand side,

everyrule lo callysatisestherestriction ( ).

ThesemanticsofaMini-RBLprogramisaD-program,wherethedomainD

isconstructedfromthedomainofathree-valuedlogic,andthenumb ers,where

unknownisthesmallestelement,andnumb erscannotb e compared.Everyrule

isinterpreted asafunction.

(6)

>

>

0 0

0

2

111111

0 3

n

n

n

low low hig h low hig h hig h

4 Concurrent Execution of Rules D

w w D

D D

w D

:

ptt>

ptt

v

q

q ;v

q v q =q q q ; : v =q q

v Corollary 3.8

Example 3.9

Example 3.10

{

{

Ifeveryprop erlyincreasingchainin isnite,thenthisholdsfor( ) .

Obviously,ifprop erlyincreasingchainsstartingwith arenitein( ) ,then

every inniteapplication

07

40

40

:=[1 ]

:=[( ) ( + )+ 05 ( + )]

Theparallelexecutionmo delofrulesinwhichwehavesharedmemoryandrule

execution canb e inprinciplesequentialized, isalreadycovered bytheprevious ing chain in is nite.Anadmissable rule-basedprogramterminateson input

,if everyproperly increasing chainstartingwith in isnite.

Proof.

The resultof an admissable rule-based program is independent

of the sequence, in whichrules are triedand red, aslong as the sequence is a

fair one. This holdsfor the three possible types of behaviour: Terminationwith

success,terminationwithfailure,and non-termination.

The following rules are taken from a rule based knowledge base

for the diagnostics of blood coagulation. The result isa certain combination of

symptoms.

IF quick THENquick-patho:=true

IF THENptt-patho:= true

IF THENptt-normal :=true

IF ptt-pathoANDtzt-pathoAND

tzy-patho ANDbzt-patho THENresult-combination-I :=true

Hereknowledge isstructuredin adecision treeand thusismoreof apropo-

sitionaltype.Theprogramterminates,sinceatsomepointintime,allvariables

arecomputed.

An exampleof anon-terminating,but sensibleD-programcon-

sists of the following tworule to compute the square-rootof some number. We

assumethatvaluesarenumbersthatarerestrictedbyintervals.Thelub-operation

inthe domainistheintersectionofintervals.Thefunctions thatextractthe val-

uesofupperandlowerboundsoftheintervalsarepermittedonlyintheexpression

on therighthandside ofthe assignment.Wedenotethe lowerand upperbound

of an intervalvariableby the suxes lowand high. Let be the input variable

and be thedesiredoutput.The rulesof the programare:

Thesetwounconditionalrulesformavalidprogramtoapproximatethesquare-

rootof the input . Since these two rules are unconditional, our interpretation

guarantees thatthe programisadmissable.

(7)

>

>

0

> >

3

2 2

2

2

2 2

1 2 2

2 21 2 1 1 2 +1 2

+1

0

0

1 2

1 1

n

n

; ;i ;i ;i ;n

i

i i

i i i i i i

i i

i i i

j

n n

i i

i

i i i

Denition4.1

Denition4.2

Theorem4.3

{

l ub

M D

8 D

b b M j b

l ubb ; b ; ;b ;b ;b ; ;b :

' 8 b M b 'b

b M b M

M

M M

M c c l ub M

M

M i b M

' 8 j c M c ' b

'

D 8

D w D

M

l ub8 w

c ;c ; M

b M

b c

Let D be anadmissable domain. The model forthe distributed

memoryisamultiset ofelementsin .Theprogramisrepresentedbya

set ofstronglymonotonicfunctions on .Therearethreetransformation

rulesforprocessing:

i.) Let and be twoelements from . Select someindex and replace

by

ii.) Takesome ,some and replace by .

iii.) Select some and addacopy of to .

This produces asequence of computations, consistingof multisets . Such

asequence iscalled . For bettersyntactic manipu-

lations,wecouldalsoremembertheexactoperationsthatleadfrom to ,

butthis isnotnecessaryforourpurposes.

From the sequence , we can dene a sequence as .

Wecallthis the sequencecorrespondingto .

A parallelexecution sequence is ifor all ,

and thereis some and some such that .

Let be an admissable semantic domain, let be a set of

strongly monotonic functions on , let be some element from

(theinput), and let beafair parallelexecution sequence.Then the corre-

spondingcompressedsequenceisanascending chainwith thelimit .

Proof.

can mo del concurrent access inshared memoryon the samevariable,or with

distributed memory,where thesamevariable mayb e inthe systemmorethan

once on dierent pro cessors . If we consider such a situation, it may not b e

p ossibleto simulate theexecutionbya sequentializedruleexecution. Sincewe

concentrateonprovingcorrectnes sofexecution,notoneciency,wewillnotuse

amo del,wherepro cessorsandchannelsareexplicit,butasimpliedmo delthat

onlymakesthedierentvalues atdierentplacesofthesamevariableexplicit.

Theideaofourmo delistoassumethateverypro cessorhasitsownmemory

foralltheglobalvariables.Thenallop erationscanb emo delledusingthreekinds

oftransformations.Therstis thattwopro cessorscommunicateand exchange

part oftheirknowledgeto construct the oftheirvalues.Thesecond isthat

somepro cessor res somerule. The third is that some pro cessor starts a new

pro cessorwithacopyof itsmemory.

( )

( )

( ( ... ... ))

( )

aparallelexecutionsequence

( ) ( ) := ( )

compressed ( )

( ) fair

( )

The fairness condition is rather natural and forces every function to b e

appliedasoftenasrequired.Itprevents,forexample,uselesscomputationswhich

aredominatedbycopy-op erations

( ) ( )

( )

( ( ))

Let ...b ethecompressedsequencecorresp ondingto .Nowcon-

structafairsequentialsequence( ) from asfollows:

:=

(8)

3

i i

{

nf g

2

+1 +1

+1 +1

1 1

+1

+1 +1 +1 +1 +1

+1 +1

+1

1 1 +1

1 1 +1 +1

0

5 Monotonic Operatorsand Truth-Preserving Conditions

i i i i

i i i i

i i

i i

i i

i i

i i i i i i i

i i i i i

i i

i i

j i

i i

i i

i i

i i i i i i

i j j i

M M ' b ' b

b

c b

b c i i b c

M M

c c b b b c M

M ' b 'b ' c c

' c l ub M

c l ub M d ;' d d

'

i j c b

d

d c d 'd ' 8

' b

d b i d b d 'd 'b b

d M c b

l ub 8 w

t

k now n k now n

cond

If isconstructed from byapplicationof ,then := ( ).

Thesequence ( ) is fairinthe sequential sense, since it is also fairin the

parallelsense.Nowwe showthatthetwosequence s ( )and( )havethesame

limit.

1.) for all : B y induction on . We have = , hence the relation

holds. If is constructed from by a lub or copy op eration, then

= and = , hence . If is constructed from

by an application of a function , then = ( ) ( ) ,

since is monotonic. The last inequation holds, since = ( ), and

= ( ( ))forsome .

Sinceevery musto ccurinnitelyoften,wecan constructafairsequential

sequence thatdominatestheparallelsequence ofcompressedenvironments.

2.) Forevery thereexists some such that :

By thefairnesscondition,we canconstruct asequence ( ) as follows.We

let = and theelementthat isgreater than ( )forsome .

We can cho osethe samesequence of 'sas forthesequence ( ).Thuswe

get byinductionon ,since = and ( ) ( )= .

Since iscontainedinsome ,wealsohave

Nowwe haveshownthatafairparallelsequence hasthesamelimitasafair

sequentialsequence ,hence thelimitis equalto ( ( )).

Theorem4.3showsthatifanadmissablerule-basedprogramisconcurrently

executed in a distributed environment, then the result is the same as in the

sequentialcase,ifsomefairnessconditionshold.Aterminationconditioninthe

parallelexecution case could b e to stop, ifthere is somepro cessor that fullls

aterminationconditionsimilarto thesequentialone,i.e.,thereisnomorepro-

gramrulethatmakesprogressinthecompressedsequence.Thisconditionisnot

eective asadistributedalgorithm.Theinvstigationofpragmaticaltermination

testsisb eyondthescop eofthispap er.Usingstrongerconditions,itisp ossibleto

showthattheknowledgeofthewholedistributedcomputationisalsoeventually

availableonsomesinglepro cessor

Inthissectionwe exhibitsomegeneralconditionswhicharesucientto ensure

the monotonicityofthe functions that corresp ond torules. Therst condition

isthattheexpression ontherighthandsideofanassignmentmustcorresp ond

to a monotonicfunction.This excludes, for example,the use of functions like

?intheassignmentpart,since ?isnotmonotonic.Afurthercon-

ditionwhichwemusthave isthatevery inaruleremainstrue,afteritwas

evaluated to true. In the following we investigate these requirements in more

detail.

(9)

>

>

n

i

n new

old

n

n m

n

!

)

2

!

2f

g

_ ^ :

0 3

>

!

_ ^

! f g

Denition5.1

Theorem5.2

Lemma 5.3 {

{

Lemma 5.4

Lemma 5.5

' D D v w

'v tr ue ' w tr ue

D D x y x y

x;y D fal se tr ue fal se tr ue

R v t cond

D D v

l ubv ;t

R

D

' v w cond v ;condw

unk now n;unk now n ; unk now n;fal se ; fal se;false; unk now n;tr ue ;

fal se tr ue ; tr ue tr ue '

v l ub w ;t v

l ubv ;t v l ub w ;t w v w t v t w

condv ;condw

tr ue;fal se tr ue;unk now n l ub v ;t v w

t v w

; ; ;= <; ; ; ;>

D D

fal se unk now n tr ue

pr ov ed tr ue tr ue fal se

uuf fal se tr ue unk now n

exact d;I

d

' D unk now n;fal se;tr ue

A function is called , i

and implies that .

Let \IF cond THEN " be a rule. Consider

as a function: , and let the assignment be interpreted as

.

If cond istruth-preservingand tismonotonic,then isstronglymonotonic

on .

Proof.

The functions , and aremonotonic.

the functions and arithmeticcomparisons aremono-

tonic, wheredivisionby zeroresultsin aglobalerror,i.e., .

The followingfunctions are -monotonic:

i.) tupling,projection,and compositionof -monotonic functions: .

ii.) the known?-function that is for ,otherwise

iii.) The function ,that is for ,otherwise .

iv.) The functions and .

v.) The function ,that is for ,otherwise .

vi.) In thecontextof intervalarithmetic,the function ,thatistrueif

the intervalIislessor equal .

The following functions are

truth-preserving:

i.) -monotonic functions.

: truth-preserving

( )= ( )=

Let b eanextensionoftheorder on and ,suchthat

for and fortheb o oleanvalues and ,such that

isthe smallest such ordering. We willalso freely use this notionsfor tuple-

valuedfunctions,inthiscaseeverycomp onentmustsatisfythetruth-preserving

condition.

Usingtruth-prese rvingconditionswecan givearathergeneralconditionfor

aruletob e stronglymonotonic:

= =

( ) :=

( )

( )

Let b eatruth-preservingconditionandlet .Then( ( ) ( ))

( ) ( ) ( ) ( )

( , ) ( , ) . In therst threecases thefunction is theiden-

tity.Inthelastthree cases truth-preservation requires that ( ( ))or

( ( )) ( ( )).Thetwoequationshold,since and ( ) ( ).

It is instructive to consider the forbidden cases that ( ( ) ( )) is

( ) or( ).Inthesecases theinequation ( ( ))

isrequired,whichholdsonlyintheveryrestricted casethat ( ) .

+ =

?

( )

Thefollowinglemmadescrib essometruth-preser vingfunctionsthatarep er-

mittedasconditionsinadmissablerules.

:

(10)

1 2 3 k

h k

k

h k h

6 Application to fuzzy values Corollary 5.6

{

{

Example 5.7

{

{

!

!

!

!

:

:

_ ^ :

_ ^

^

_: ^ _ :

:

_

x:f g x f D D

g D D

f D D

g D D v w D

g v g w g v g w f

f g v f g w

k now n

x k now n x

; ;

; k now n

k now n x k now n y

x>y k now n x k now n x x x;y ; x>

y

f f unk now n fal se f fal se

unk now n f tr ue tr ue

k now n f x k now n f fal se fal se

k now n f unk now n tr ue

k now n x

tr ue unk now n tr ue

; ; ;

iii.) The composition of a -monotonic function and a

monotonic function .

Proof.

Thefollowingconditions inMini-RBL aretruth-preserving.

Anarbitrarycondition, whereonlythe booleanoperators areused

Acondition,whichcanbeseenasthe compositionofafunctionthatiscom-

posedsolelyof ,and ,andanothertuple-valuedBooleanfunction

that ismonotonic.

These examples show that composition is not compatible with

truth-preservationand with .

Thecompositionoftwotruth-preservingfunctionsmaybenottruth-preserving.

For example, let be dened such that

and . Then f istruth-preserving.Thecomposition

isnottruth-preserving,since and

.

the composition of a monotonic with a -monotonic function may be not

-monotonic. The standard exampleis .

( ( )) :

:

Weprove onlythelast part,theotherones aretrivial.Let :

b e -monotonicand : b emonotonic.Let b eelementsin .

Then ( ) ( ),hencealso ( ) ( ).Since isalso -monotonic,wehave

( ( ) ) ( ( )),hence thecomp ositionistruth-preser ving.

Thefunction ismonotonic,butnot -monotonicandnottruth-preser ving.

Thesameholdsforlogicalimplication.Thefunction ?is notmonotonic,

but -monotonicandtruth-preserving.Thefunction ( ). ( ?( ))isalso

nottruth-preser ving.

?

An example for a truth-prese rving condition is ?( ) ( ?( )

( )),whichiscomp osedas ?( ) ( ?( ) ) ( (

)).It isnothardto syntactically checkthese conditionsduring compilationof

aMini-RBLprogram.

( ) = ( ) =

( )=

?( ( )) ?( ( ))=

?( ( ))=

( ?( ))

Ifweapplythemetho dtonumb erswhichareknowntob einsomeinterval,then

the semi-latticeissimplythelatticeof intervalsorderedbythesup erset order-

ing,andtheemptyintervalisomitted.Itisnothardtodeterminetheop eration

of functions onintervalsgiven functions on elements, thefunctions aresimply

liftedtosets.Thismetho densures thatfunctionsonintervalsaremonotonic.If

anintervalcontainsonlyone element,thenthevaluecanb e consideredunique,

andhenceknown.Forexample,thisgivestheequations =

and [1 2]+[4 5]=[5 7].It is also p ossible to have a b etter approximation,if

(11)

i i

i i

i i

_:

3

f 0 3 g

:

: 7 The Usage of Defaults

x x x

tr ue

A ;A B B A

A B unk now n

A ;B unk now n

k now n Exact e;x

tr ue x e

k now n

IL

l eng th ; l eng th ; ; ;

k now n exact

IL

k now n x

NO T k now n v v

NO T k now n v v

v v

k now n x in0,regardlessof thevalueof . Thesameholdsfor which can always

b e replacedby . This viewofthesemantics ofunknown p ermitsto useall

algebraic lawsto evaluateexpressions. However,dierent strength ofalgebraic

manipulationsmayresultindierentoutcomesofthesameprogram.Forexam-

ple,inthecaseofintervalarithmetic,thedistributivelawincombinationwitha

mo dulardenitionof and+maydecrease theexactness ofapproximations.If

acompilerusessuchalgebraicmanipulationsorsimplications,thenthisshould

onlyb edone,ifab etterapproximationresults.

Suchanimprovementcanalsoexhibithidden\conictingfacts",forexample,

lettherulesb e := 2 := ( ) Withoutalgebraicsimplications,

the Mini-RBL program started with = = terminates with

= 2 = . After algebraic simplication, the execution is halted

with\conictingfacts".

Intheintervalcaseanop eratorcorresp ondingto ?wouldb e ?( ),

which is ,ifthelengthoftheintervalfor isnotgreater than .Itcan b e

used ina similar way as the ? -op erator. Supp ose, we have a function

, that computes the length of an interval. This function is not monotonic,

since [0 3]=3, [1 2]=1,we have [0 3] [1 2],but not3 1in

theinformationordering . Thusthe functions ? and ? aretruth-

preservingandcanb eusedinconditions,iftheyarenotunderanegation.The

function ,andtheextractionofupp er andlowerb oundaryoftheintervalsis

notmonotonicandshould b eillegalinconditions.

Ifexpressions like ( ?( ))areusedtoimplementdefaults,thentheorder

ofruleexecutionplaysarole. Forexample,considerthetworules

IF ( ?( ))THEN :=1

IF ( ?( ))THEN :=2

Ifwe usethemwithoutprecaution,thentheresultmayb e =1,or =2,

dep endingonthesequenceofexecution,andtherealsoisnop ossibilitiytodetect

thiserrordynamically,since onceone rulehasred,b othrulesb ecomeinappli-

cable.Aswe haveseen inthelastparagraph,theconstruction ( ?( ))is

nottruth-prese rving,and thusdo es notsatisfytheconditionsoftheorem5.2.

Toremedythiswep ermitsuchdefault-rules,splittheprogramintoa\normal

part" and a \default part". The normal execution of the program consists of

ringtherulesinthenormalpart,andto retherulesinthedefaultpart only

inthe case, where the normal part of the programhas terminated. One must

ensure,however,thatthedefaultsarenotconicting,sinceotherwise,onewould

reintro duce adep endence oftheresult onthe orderofexecution. Theexample

ab oveis such asetofconicting defaults. Acorrect interpretation wouldb e to

keep the variable values xed, collect all results of the default rules, and add

the lub of all the outcomes, with a certain bad chance of getting as answer

\conictingfacts".

(12)

3

3

Constraints

8 Comparison with other Approaches fal se

unk now n

notk now n A A

B ;C unk now n

A unk now n

A x A

usual cycleofringnormalrulesuntiltheprogramterminates,or theprogram

stops afterringthedefaultrules.Therearesomereasons (seeb elow)toprefer

thesecond one.

Another, more subtle metho d would b e to also p ermit the application of

default rulesiftheprogram statusensuresthat thedefaultconditionsare true,

and cannot b echangedto byother rules.Inapracticalimplementation,

thiscanb edonebystoppingtheprograminterpretation,insp ectingthecurrent

program status, and then executing all the defaults. In order to have a clean

lo op breaking metho dsuch that theresults do notdep end on thetime of the

break,itmustb eensured thattheapplicationofdefaultsb ehavesasifthelimit

wasalreadyreached.Thismetho dofusingdefaultsensuresthatprogramshave

auniqueresult.

Ifthecompilermakes useofalgebraic lawsto simplifyexpressions,and the

programusesdefaults,thentheoutcomeofthewholeprogrammaychange,since

forexample,therstexecutionofallnon-defaultrulesmaypro duce for

acertain variable,but after algebraicsimplication,thevalueb ecomes known.

In the rst case, a default may b e applicable, wheras in the second case the

default rulesarenolongerapplicable.Inordertogiveanexample,consider the

followingrules:

A:=B*C

IF ( ?( ))THEN :=1

A criticalinputis =0 = .Theusual implementationof isthat

remains .Theprogramterminates,andthenthedefaultisredand

gives = 1. If the algebraic law 0 = 0 is applied, then is assigned 0,

and the default rule is not applicable. For sensible programming, this means

that defaultsshould onlyb e used as a last resort, for examplefor preparing a

readable formoftheoutput, butnotasanormalprogrammingdevice.

Inthisparagraphwewanttocommentonthep ossibilitiestoimplementtheMini-

RBLmetho dinotherparadigms.Theissueisadequacy ofsuch anemb edding.

(1) (cf. [Win92]) can express dep endencies b etween variables and

p erform the same computations for a subset of the Mini-RBL programs.

Constraintsare notdirected, whereas rulesare directed inthe sense, that

a single rule has a xed input and as output a new information on the

variable in the assignment. Thus Mini-RBL programs cannot b e used in

a backward direction. The advantage of Mini-RBL programs is that also

cyclic dep endencies can b e enco ded and lead to a stable output or to an

approximation of the output, whereas constraint systems require a direct

metho dfor nding thesolution,or if constraint propagation is used, some

kindof oscillationmayo ccur,ifcyclicdep endencies aregiven.

(13)

k now n pr ov ed exact

notk now n x 9 Conclusion

Acknowledgements Functionalprogramming

Rulesasimplications

ofalogicprogramamountstocomputingnewfacts,thusapproximatingthe

minimalmo del in a xed-p oint computation. Globalvariables as in Mini-

RBLcan b eenco ded as predicates andcorresp ondingfacts.Themanipula-

tion must b edone using Assert, Retract (or setval, getval),and ap ossible

computationof least upp er b ounds would b e ametho dto mo difyasserted

facts. This manipulation metho ds are not a p ossible in a pure subset of

Prolog, hence itis notclear,howtheexistence ofaminimalmo delcan b e

guaranteed.

(3) .([BW88],[Dav92])Purefunctionalprogrammingas

abasisforMini-RBLhasseveralproblems.Non-mutablevariablesarene,

however,evenmo difyingglobalvariablesfromunknowntoavalueisnotp os-

sible inpurefunctionallanguages.Ifthe functionallanguagep ermitssome

non-puretechniquesinitsI-O-pro cessing(cf.[SA92]),thentheemulationb e-

comesmoreadequate.However,thep ossiblecyclicityofvariabledep enden-

ciesinMini-RBLcannotb edirectlytranslatedintothefunctionalparadigm,

and mustb e checked inorder to prevent innitelo ops. This translation is

studied indetailin[Mo o93].Thep olymorphictyp e-disciplineoffunctional

programmingiseasilyadaptable toextensions ofMini-RBL,aslongas the

information-orderiscompatiblewiththetyp estructure.

(4) .Ifpro ductionrulesareseen astwo-valuedlogicalim-

plications,thenthe corresp ondingrulebased programshave theprop erties

ofb eing indep endent ofthesequence ofexecution.Inordertosimulateour

programmingparadigmusingimplicationalrules,thelogicmustb eatleast

athree-valued one.In this case,there mustb e somenon-determinism(see

theexamplesinSection7),andtheresults ofthispap erareapplicable.

Wehaveshownthatsomerestrictionsontheusageofpro ductionsystemsp ermits

tohaveacleanandnicesemanticsofPSG-programs.Theconsequence sarethat

theresultofaprogramisindep endentofthesequenceoftheexecutionofrules.

A further result is that parallelization of rule execution, even ina distributed

environment,leadsto thesameresultsas sequentialexecution.

A clear distinction can b e made b etween legal and illegal usage of several

op erators, like the ?, ?, and ?- op erator. Furthermore, the

usageof ( ?( ))for defaultscan b ep ermitted ifthe interpretationof

defaultrulesdiersfromtheinterpretationof otherrules.

IwouldliketothankBernhardPohl,FrankPupp e,Sven-EricPanitzandMarko

Sch utzforreadingadraftofthispap er.

(14)

Programming Expert

SystemsinOPS5

TheMYCINexperimentoftheStanford

heuristicprogrammingproject

Introduction to functionalprogramming

ProgramminginProlog

An introduction to functionalprogramming systems using

Haskel l

AutomatedDeductioninMultiple-ValuedLogic

Foundations of Logic Programming

Meth.Inform.Med.

The ArtofPROLOG

Denotationalsemantics,theScott-Stracheyapproachtoprogram-

minglanguagetheory

Pro.M.D. Medizinische Diagnostikmit

Expertensystemen

Handbookofphilosophicallogic

ArticialIntelligence

[BFKM85] L.Brownston, R.Farell, E.Kant, and N.Martin.

. Addison-Wesl ey,Reading,1985.

[BS84] B.G.BuchananandE.H.Shortli e.

.Addison-Wesl ey,Reading ,1984.

[BW88] Richard Bird and Phil Wadler. .

PrenticeHall, 1988.

[CM91] W.F.Clo cksin andC.S.Mellish . . Springer-Verlag ,

NewYork,1991.

[Dav92] A.J.T.Davie.

.Cambridge UniversityPress,Cambridge,1992.

[GK91] R.Glas and A.Kno che. Semantische Fundierun g der asynchron prozedu-

ralen Sprache DONUTSim AEM. Forschungsb eri cht 1991/3, Technische

Universitat Berlin,Fachb ereichInformatik,Germany,1991. in German.

[Gla90] R.Glas. EinabstraktesEnvironmentMo dell(AEM)zurBeschreibungpar-

allelenundasynchronenVerhaltens. Forschungsb ericht1990/3,Technische

Universitat Berlin,Fachb ereichInformatik,Germany,1990. in German.

[Hah93] R.Hahnle. .OxfordUniver-

sityPress,Oxford,1993.

[Llo84] J.W. Lloyd. . Springer-Verlag, New

York,1984.

[Mo o93] Marcus Mo os.



Ub ersetzung von Pro.M.D.-Wissensbasen in funktionale

Sprachen. Master'sthesis, FBInformatik,J.W.Go ethe-Universitat Frank-

furt,1993.

[PT88] BPohl and Chr. Trendelenburg. Pro.M.D.- A diagnostic exp ert system

shellforclini calchemistrytestresultinterpretation. In ,

volume27,3,pages111{117,1988.

[SS86] L.Sterling andE.Shapiro. . MIT-Press,Cambridge

Mass.,1986.

[Sto81] J.E.Stoy.

.MIT-Press,CambridgeMa.,1981.

[TP90] Chr. Trendelenburg and B.Pohl.

.Thieme-Verlag,Stuttgart,Germany,1990. inGerman.

[Urq86] A.Urquhart. Many-valuedlogic. In ,volume

I I I,pages71{116,1986.

[Win92] P.H.Winston . . Addison-Wesl ey, Reading,thirdedi-

tion,1992.

Thisarticlewaspro cessedusingtheLT

E

XmacropackagewithLLNCSstyle

Referenzen

ÄHNLICHE DOKUMENTE

If one denotes the sequence of all positive literals of a goal F by F + and the sequence of all negative literals by F~ then one can define the notions of an e-goal for an e-program

When Tarski’s World asks you to choose a conjunct you think is false, pick the first sentence. This is not the false conjunct, but select it anyway and see what happens after you

However, assigning a truth value to If the car does not start then normally the battery is flat, is not obvious at all; indeed such a truth value does not make sense for instance

One of the approaches for context-rule based change operations for variant creation most related to this work is presented in [HBR09], which also specify variant points in a

As they are either applied to the composer itself or to a certain slot, they can either react to all composition actions of the entire appli- cation or only to actions that modify

It is conventional wisdom in machine learning and data mining that logical models such as rule sets are more interpretable than other models, and that among such rule-based

In contrast to the differential case, stochastic fragments have the property that the probability of being in a concrete state (a state which is counting copy numbers of

The issue explored in this experiment was whether the DCU output con- tained sufficient information after the application of the ordered rewrite rules (core component of this thesis)