• No results found

Positive Boolean Functions as Multiheaded Clauses

N/A
N/A
Protected

Academic year: 2019

Share "Positive Boolean Functions as Multiheaded Clauses"

Copied!
16
0
0

Loading.... (view fulltext now)

Full text

(1)

      

City, University of London Institutional Repository

Citation

:

Howe, J. M. and King, A. (2001). Positive Boolean Functions as Multiheaded

Clauses. Paper presented at the International Conference on Logic Programming, 26 Nov -

01 Dec 2001, Cyprus.

This is the unspecified version of the paper.

This version of the publication may differ from the final published

version.

Permanent repository link: http://openaccess.city.ac.uk/1697/

Link to published version

:

Copyright and reuse:

City Research Online aims to make research

outputs of City, University of London available to a wider audience.

Copyright and Moral Rights remain with the author(s) and/or copyright

holders. URLs from City Research Online may be freely distributed and

linked to.

City Research Online:

http://openaccess.city.ac.uk/

[email protected]

(2)

Multiheaded Clauses

JaobM.Howe

?1

andAndyKing

2

1

DepartmentofComputing,CityUniversity,London,UK

2

ComputingLaboratory,UniversityofKent,Canterbury,UK

fj.m.howe,a.m.kingguk.a.uk

Abstrat. Boolean funtions are ubiquitous in the analysis of

(on-straint)logi programs.ThedomainofpositiveBooleanfuntions,Pos,

has been used for expressing, for example, groundness, niteness and

sharingdependenies.TheperformaneofananalyserbasedonBoolean

funtionsis ritiallydependentontheway inwhihthe funtionsare

represented. This paperdisusses multiheadedlauses as a

representa-tion of positive Boolean funtions. The domain operations for

multi-headedlausesareoneptuallysimpleandanbeimplemented

straight-forwardlyinProlog.Moreovertheseoperationsgeneralise thoseforthe

less algorithmially omplex operations of propositional Horn lauses,

leadingtonaturallystratiedalgorithms.Themultiheadedlause

repre-sentationisusedtobuildaPos -basedgroundnessanalyser.Theanalyser

performssurprisingly welland sales smoothly,not requiring widening

toanalyseanyprograminthebenhmarksuite.

Keywords.Abstratinterpretation,(onstraint)logiprograms,Boolean

funtions,groundnessanalysis.

1 Introdution

Booleanfuntionsplayanimportantroleinthepratieofstatianalysis.Many

analysesare ouhedin termsof Boolean funtions,andmanipulation of these

funtions is ruial to the performane of any implementation. In partiular,

positiveBooleanfuntions havebeenapplied to theanalysis of logiprograms

forpropertiessuhasgroundness,rigidity[15℄,niteness[3℄andsharing[8℄.This

paperadvoatesrepresentingpositiveBooleanfuntionsasmultiheadedlauses

andarguesthatPrologiswellsuitedtotheirmanipulation.

Thehoieofabstratdomainforapartiularappliationinvolvesthe

strik-ingofabalanebetweeneÆienyandpreision.Thevariouspropertiestraked

usingpositiveBooleanfuntionsgiveriseinpratietodierentformsofBoolean

funtion. Hene, in some appliations, restriting to a more omputationally

tratable sublassof Pos anhaveasigniant impatonpreision(for

exam-ple,goal-independentanalysisoflibraryode),whilstinotherslittlepreisionis

lost (forexample,goal-dependentgroundnessanalysis).Elsewhere, theauthors

(3)

19℄.Here,withaneyeto awiderrangeof appliations,theauthorsadapt

teh-niquesfrom thesesublassesto Pos.

Traditionally, Booleanfuntion manipulation hasbeenperformedusing

bi-nary deision diagrams (BDDs). Groundness analysis is one of the most

im-portant topis in the stati analysis of (onstraint) logi programs and from

a logi programming point of view this analysis is the most pratial test of

Booleanfuntionmanipulation.BDD-basedanalysershaveonsistently

outper-formed those based on other representations of Boolean funtions [1,2,10,24℄

for groundness analysis, but there has been a ontinuous stream of work on

representations amenable to Prolog implementation [7℄, in partiular for the

sublassofdenitepositivefuntions,Def[12,13,19℄.Themajorityofthese

im-plementations,inludedthosebasedonBDDs,requirewideningtoanalyselarge

benhmarks.

TheDef-basedgroundnessanalyserdesribedin[19℄doesnotrequire

widen-ingand wasdesignedsothat themostfrequentlyalleddomain operationsare

themost lightweight.Thesamedesign methodologysuggeststhat aPos-based

analyser should represent Boolean funtions as onjuntions of multiheaded

lauses.Infat,in[1℄(redued)onjuntivenormalform,(R)CNF,was

investi-gated,and\performedreasonablywell",butwasultimatelyrejetedsineBDDs

performed 40% faster and, in C (their implementation language), onjuntive

normal form isno easierto odethan BDDs. Surprisingly,onjuntivenormal

formshavenotbeenonsideredsine.Thispaperrevisitslausalrepresentations

of Pos sine, in Prolog, lausal representations are muh easier to ode than

BDDs and following the methodology of [19℄ the lausal representation lends

itselfto eÆientimplementation basedonentailmentheking.

Theimportane ofthe hoie of representation islearly illustrated bythe

subtledierenebetweenmultiheadedlausesandRCNF.TheRCNF

represen-tationis reduedin thesensethat nolause subsumesanother.Thisredution

makes meet for RCNF quadrati in the size of the representation. The

mul-tiheaded lause representation may ontain redundant lauses, enabling meet

to be onstanttime. This is an important issue for performane sinemeet is

by far the most frequently applied operation. Neither multiheaded lause nor

RCNFrepresentationsareinaanonialform,thereforeequivaleneannot be

deteted by straightforward syntatiidentity. In [1℄ equivalene for RCNF is

determined by omputing the dual Blake anonial form of the formulae and

thentestingforsyntatiidentity.ThedualBlakeanonialformmaybe

expo-nentiallylargerthantheRCNFrepresentation andmust alwaysbe ompletely

omputed.Thereforethemethodisnotamenabletolteringthroughlower

om-plexityalgorithms.Logialentailment,ratherthansyntatiequivalene,ismore

exible. In pratie,entailment offormulaeanoftenbe detetedusing an

in-ompletelowomplexityalgorithm.Usingsuhahek,manyallstotheworst

asealgorithmanbelteredout.Itisthisstratieduseofentailmentheking

(4)

and blokdelarations,whilst meet redues to listonatenationimplemented

usingdierenelists.Themajorthemesandontributionsofthisworkare:

Posfuntions anbenaturallyexpressedasmultiheaded lauses,whih are

partiularlystraightforwardtounderstand,manipulateand ode.

Theentailmenthekingalgorithm (whih ispotentiallyexponentialin the

numberofvariables)isstratiedsothat heksfornaturallyourring

sub-lassesofformulaetakequadratitime(inthesizeoftheformulae);in

par-tiulartheforwardhainingalgorithmforpropositionalHornlausesis

sub-sumed.

Thedomainoperationsformultiheadedlausesmaybeodedsuintlyand

eÆiently in Prolog, resulting in fast Pos-based goal-dependent and

goal-independent groundness analysers whih do not require widening for any

programin thebenhmarksuite.

If widening is required, the representation may be simply and naturally

widenedtoDef ortothesimplerdomainEPos.

Theanalysersagaindemonstratethe valueofaprinipledapproahto the

designofastatianalysis.

An experimental evaluation of the analysers is given illustrating that a

lausalrepresentationofPosodedinProloggivesperformanesomparable

toBDDrepresentationsoded inC.

Therestofthispaperisstruturedasfollows:Setion2introduesthe

nees-sary tehnialbakgroundmaterial. Setion3details multiheadedlauses.

Se-tion4givesalgorithmsfortheabstrat operationsofPosrepresentedas

multi-headedlauses.Setion5desribesPos-basedgroundnessanalysersimplemented

with Booleanfuntions representedasmultiheaded lauses. Setion 6 givesan

experimental evaluationof these analysers.Setion 7reviewsrelated work and

Setion 8onludes.

2 Preliminaries

A Boolean funtion isafuntion f :Bool

n

!Bool where n0.LetV denote

adenumerableuniverseofvariables. ABooleanfuntionanberepresentedby

a propositional formula overX V where jXj = n. The set of propositional

formulaeoverXisdenotedbyBool

X

.Throughoutthispaper,Booleanfuntions

and propositional formulae are used interhangeably without worrying about

thedistintion.Theonventionofidentifyingatruthassignmentwiththesetof

variables M that it mapsto trueis alsofollowed. Speially,amap

X

(M):

}(X) ! Bool

X

is introdued dened by:

X

(M) = (^M)^:(_(XnM)). In

addition,theformula^Y isoftenabbreviatedasY.

Denition1. Themap model

X

:Bool

X

!}(}(X))isdened by:model

X

(f)

=fM Xj

X

(M)j=fg.Also,ountermodel

X

:Bool

X

!}(}(X))isdened

by:ountermodel

X

(f)=}(}(X))nmodel

X

(f).Observethatmodel

X

isbijetive,

henemodel

1

:}(}(X))!Bool

X

(5)

EPos fx;yg

x^y

x

x$y y

Def fx;yg

x^y

# # x

x$y y

x y y x

# # Pos fx;yg

x^y

# # x

x$y y

x y

x_y

y x # # # #

Fig.1:Hassediagrams

Example 1. IfX=fx;yg,thenthefuntionfhtrue;truei7!true,htrue;falsei7!

false,hfalse;truei7!false,hfalse;falsei7!falseganberepresentedbythe

formulax^y.Also,model

X

(x^y)=ffx;yggandmodel

X

(x_y)=ffxg;fyg,

fx;ygg.

Thefousof this paperis on the use ofsublasses of Bool

X

in traing

de-pendenies.Thesesublassesaredened below:

Denition2. A funtion f is positive i X 2 model

X

(f). Pos

X

is the set

of positive Boolean funtions over X. A funtion f is denite i M \M

0 2

model X

(f) for all M;M

0

2 model

X

(f). Def

X

is the set of positive funtions

overX thataredenite.A funtionf isGEif isdenitepositiveandforall

M;M

0

2model

var(f)

(f),jMnM

0

j6=1.EPos

X

isthesetofGEfuntionsoverX.

Note that EPos

X

Def

X

Pos

X

. Also notie that EPos

X

= f^F j F

X[E

X

g,whereE

X

=fx$yjx;y 2Xg.

Example 2. SupposeX =fx;y;zgandonsiderthefollowingtable,whihstates,

forsomeBooleanfuntions,whethertheyareinEPos

X ,Def X orPos X andalso givesmodel X . f EPos X Def X Pos X model X (f)

fal se ;

x^y f fx;yg; fx;y;zgg

x_y f fxg;fyg; fx;yg;fx;zg;fy;zg;fx;y;zgg

x y f;;fxg; fzg;fx;yg;fx;zg; fx;y;zgg

x_(y z) f;;fxg;fyg; fx;yg;fx;zg;fy;zg;fx;y;zgg

true f;;fxg;fyg;fzg;fx;yg;fx;zg;fy;zg;fx;y;zgg

Note that x _y is not in Def

X

(sine its set of models is not losed under

intersetion)andthat falseisneitherinEPos

X

,norPos

X

, norDef

X .

The 4-tuple hPos

X

;j=;^;_i is a nite lattie, where true is the top

ele-ment and ^X is the bottom element. The set of (free) variables in a

syn-tati objet o is denoted by var(o). Existential quantiation is dened by

Shroder'sEliminationPriniple, that is, 9x:f = f[x7!true℄_f[x7! false℄.

Also,9fy

1

;:::;y

n

g:f (projetout)abbreviates9y

1

:::::9y

n

:f and9Y:f (projet

onto) denotes 9var(f) nY:f. Two funtions f;f

0

are equivalent, f f

0 if

and only if f j= f

0

and f

0

j= f. Finally, for any f 2 Bool

X

, oneg(f) =

model 1

(fXnMjM2model

X

[image:5.612.130.490.66.152.2] [image:5.612.140.474.404.484.2]
(6)

ABooleanfuntionispositiveifandonlyifeverylauseinitsonjuntivenormal

formrepresentationontainsatleastonepositiveliteral.Alauseisdesribedas

multiheadedifitontainsoneormorepositiveliterals.Inthispaper,multiheaded

lausesarewrittenasimpliationswiththebodyaonjuntionofvariablesand

theheadadisjuntionofvariables.Thatis,amultiheadedlausehastheform:

y 1

^:::^y

n

!x

1

_::_x

m

Observe that the y

i

and the x

j

are distint variables, otherwise the lause is

equivalentto true.Letf 2MHCdenotethatf isrepresentedasaonjuntion

ofmultiheadedlauses.

Proposition1. Foreveryf 2Posthereisf

0

2MHCsuh thatf f

0 .

Proof. It is well known that any Boolean formula is equivalent to another in

onjuntive normal form. Suppose f f

0

, where f

0

is in onjuntive normal

form.Sine f is positive, everylause of f

0

must ontainat least one positive

literal,henef

0

2MHC.

In the ase that m = 1 the multiheaded lause is simply a propositional

Horn lause. This suggests that the algorithms to alulate the domain

oper-ations might performwell ifthey naturallyspeialiseto eÆient propositional

Hornlausealgorithms.Thiswillbetheaseforentailmentheking.Moreover,

themultiheaded lausesrepresentationispartiularlyamenableto widening.If

wideningisrequired,therepresentationmayberestritedinlineartimeso that

lauses with more than, say n, heads are disarded. If n = 1, this widening

orrespondstorestritingtoDef.

4 Domain Operations for Multiheaded Clauses

This setion givesalgorithms for the domain operationsof Pos represented as

multiheaded lauses. Meet (^) is simply onjuntion of lauses and is

on-stanttime;theotherdomainoperationsdesribedarejoin (_),relative

pseudo-omplement (!), entailment heking (j=) and projetion out (9). The

algo-rithms form thebasis ofthe groundnessanalyser whose implementation is

de-sribedin thenextsetion.

4.1 Join

Consider f = f

1

_f

2

, where f

1

;f

2

2 MHC. Suppose f

1 = 1 ^:::^ n and f 2 =d 1

^:::^d

m

. Then, distributing,f f

0 =^ n i=1 (^ m j=1 ( i _d j )).Suppose i = y 1

^:::^y

k

! x

1

_:::_x

l

and d

i

= u

1

^:::^u

p

! v

1

_:::_v

q . Then i _d i y 1

^:::^y

k

^u

1

^:::^u

p

! x

1

_:::_x

l

_v

1

_:::_v

q

2 MHC.

Henef

0

(7)

Relative pseudo-omplement has reently beenused to support bakward

rea-soning.Inpartiulartotraeontrolowbakward(righttoleft)toinfermoding

propertiesofinitial queries[20℄.

Consider f = f

1

! f

2

, where f

1

;f

2

2 MHC. Suppose f

1 = 1 ^:::^ n and f 2 = d 1

^:::^d

m

. Then, f f

0 = ^ m j=1 (_ n i=1 ( i ! d j )). Suppose i = y 1

^:::^y

k

!x

1

_:::_x

l

andd

i

=u

1

^:::^u

p

!v

1

_:::_v

q .Then i !d i = ^ l i=1 (x i ^u 1

^:::^u

p

!v

1

_:::_v

q ) ^^ k j=1 (u 1

^:::^u

p

!y

j

_v

1

_:::_v

q )

Hene f

0

2MHC.Giventhat thesizeof f

0

is exponentialin thesizeof f

1

,the

operationisexponential.However,itshouldbenotedthat manyanalysesusing

positiveBooleanfuntions(inludinggroundness) donotrequirethisoperation

to bealulated.Insuhasestheostofthisoperationisnotadrawbak.

4.3 EntailmentCheking

Entailment heking for positive Boolean funtions represented in onjuntive

normalformiso-NP omplete[1℄.However,asexploitedinSATsolving,many

of theBoolean funtions that arisein pratie anbe hekedfor satisability

with lowomplexityalgorithms. Thisobservationis exploitedby thetwo

algo-rithms detailed below. The rst, entailslite, is inomplete and takes quadrati

time in the size of the input. The seond, entailsheavy, adds ase splitting to

the rstalgorithm to obtainompleteness(whih isrequiredto guarantee

ter-minationin thexpointengine).Thisstratied algorithmusuallyonlyrequires

entailslite tobeinvokedone.

Theentailslite algorithm (seen Figure 2) is aninomplete test that a

mul-tiheadedlause is entailedby aonjuntionof multiheaded lauses:^

l i=1 B i ! H i

j= B ! H, where B = y

1

^:::^y

n

and H = x

1

_:::_x

m

. It works by

propagating deterministibindings in an attempt to detetontradition.The

algorithm terminates either when a ontradition is found or when no more

bindings anbe propagated:then Flag isreturned. Notiethat this algorithm

ontainsforwardhainingforpropositionalHornlausesasaspeialase.Also

notie that the variables are assigned values only one. The auxiliary rename

produesasyntativariantofatermwhihdoesnotshareanyvariableswith

theoriginalterm.

Thealgorithm entailsheavy (seeFigure3) appliesasesplittingifentailslite

does not detet entailment. The number of ases is potentially exponentialin

the number of variables left unbound by entailslite. However,propagation

o-ursafter eahbinding, thereforedeepasesplittingisrarelyrequired.Amore

intelligentsplittingstrategy(asinSATsolving)ouldbeapplied,butthenave

strategyperformsmorethanadequately.

Proposition2. Thealgorithmentailslite issound,butnotompletefor

(8)

proessentailslite(^ i=1

Bi!Hi,B!H)

Fl ag:=fal se;

fori=1tomdoxi:=fal se;

forj=1tondoy

j

:=true;

fork=1toldo

spawnforward(Bk,Hk,Fl ag);

spawnbakward(B

k

,H

k

,Fl ag);

returnFl ag.

proessforward(B,H,Fl ag)

blok untileveryx2Bbound

if^Btruethen spawnmaketrue(H,Fl ag)

elsestop.

proessbakward(B,H,Fl ag)

blok untileveryy2Hbound

if_Hfal sethen spawnmakefalse(B,Fl ag)

elsestop.

proessmaketrue(H=fy1;:::;ymg,Fl ag)

blok untily

i

2Hhangesforsomei2f1;:::;mg

if_Hfal sethenFl ag:=true;stop

elseif_Htruethen stop

elseif_Hy

i

forsomei2f1;:::;mgtheny

i

:=true;stop

elsesuspend.

proessmakefalse(B=fx1;:::;xng,Fl ag)

blok untilx

i

2B hangesforsomei2f1;:::;ng

if^BtruethenFl ag:=true;stop

elseif^Bfal sethen stop

elseif^Bx

i

for somei2f1;:::;ngthenx

i

:=fal se;stop

elsesuspend.

Fig.2:Theentailslite Algorithm

proessentailsheavy(F,f)

Fl ag:=entailslite(F,f);

ifFl ag=truethenreturntrue

elseV :=var(F)=fx

1

;:::;x

n g;

ifV =;thenreturnfal se

elsedo

rename(F^f)=(F

0

^f

0 );

Fl ag

0

:=entailsheavy(fx

0 1

7!truegF,fx

0 1

7!truegf);

ifFl ag

0

=truethen

rename(F^f)=(F

00

^f

00 );

returnentailsheavy(fx

00 1

7!fal segF

00

,fx

00 1

7!fal segf

00 )

elsereturnfal se.

[image:8.612.126.486.63.577.2]
(9)

Asin[19℄,projetionisalulatedusingaFourier-Motzkinstylealgorithm.The

projetionofasinglevariableoutofapairoflauses,oneofwhihontainsthe

variable in the body and the other in its head is performed by syllogising as

follows:

9z:

y 1

^:::^y

p

!z_x

1

_:::_x

q

^z^y

p+1

^:::^y

n

!x

q+1

_:::_x

m

=y

1

^:::^y

n

!x

1

_:::_x

m

TheorretnessandompletenessofthisiseasilyonrmedusingShroder

elim-ination,henethealgorithmbelowisalsoorretandomplete.Ingeneral,eah

variableiseliminatedin turn,asfollows.Supposez istobeprojetedoutoff.

1. All thoselauseswith z in theheadare found,givingfC

i

ji2Igwhere I

isa(possiblyempty)indexset.

2. Allthoselauseswithz inthebodyarefound,givingfD

j

jj2JgwhereJ

isa(possiblyempty)indexset.

3. Theselausesoff arereplaedbyf9z:C

i

^D

j

ji2I;j2Jg

4. A ompat representation is maintained by eliminating redundant lauses

(absorption).

Step4meansthatthealgorithmisparameterisedbytheompationproess.

Compationdoesnotneessarilyhavetoremoveallredundantlauses(orindeed

any), henea tradeo an be made betweenkeeping the representation small

andtheostofthismaintenane.Inprojetingoutasinglevariable,syllogising

givesaquadrati blowup in the size ofthe representation.Thus thebasiost

of projetingout asingle variable is quadrati. However, theompation step

takesasitsinputarepresentationquadrati inthe size oftheoriginal andthe

overallost isdependent ontheompationalgorithm.Intheimplementation,

entailslite is used for ompation therefore the ost of projeting outa single

variableisquarti.Beauseofthesizeblowup,projetinganarbitraryfuntion

ontoaniteset ofvariablesisexponential.

5 A Pos -Based Groundness Analyser

Toassesstherepresentation,twoPos-basedgroundnessanalysersbuilton

multi-headedlauses wereimplementedin Prolog:one goal-dependentand one

goal-independent.Theanalysersillustratetheeasewithwhihthemultiheadedlause

representation anbeused. Theanalysers performsurprisingly well ompared

withotherPosanalysers(inludingthosewithBDD-basedBooleanfuntion

ma-nipulationodedinC)andomparedwithanalysersusingmoreomputationally

tratabledomains.This setiondetailsthePrologimplementation.

5.1 A GEPRepresentation

As in [2,19℄, the analyser maintains a fatorised representation, that is, as a

(10)

pat-tion(list)ofmultiheadedlauses.Inanon-groundrepresentationthearguments

of aan beinstantiated and aliasedto express simpledependenyinformation

[17℄. For example, if a = p(x

1

;:::;x

5

), then the atom p(x

1

;true;x

1

;x

4

;true)

representsaoupledwiththeformula(x

1

$x

3

)^x

2

^x

5

.Thisenablesthe

ab-strationhp(x

1

;:::;x

5

);f

1

itobeollapsedtohp(x

1

;true;x

1

;x

4

;true);f

2 iwhere f 1 = (x 1 $ x 3

)^x

2

^x

5

^f

2

. This enoding leads to a more ompat

rep-resentation and is similar to the GER fatorisation of ROBDDs proposed by

Bagnara and Shahte [2℄. The representation of all and answer patterns

de-sribedaboveisalledGEP(groundness,equivalenesandpropositionallauses)

wheretheatomapturesthersttwopropertiesandtheformulathelatter.

TheGEPrepresentationis advantageoussineit givesaompat

represen-tation whilst inurring little overhead when the representation is non-ground.

Theompatnessoftherepresentationaets memoryusageandthe

omplex-ity ofdomain operations.As demonstrated in [17℄,manydependenies arising

ingroundnessanalysisfallintotheGEomponent.ByusingtheGEP

represen-tation, many alls to expensive domain operations are avoided. Note that (as

in [19℄) theanalyserdoesnotmaintainthefatorisation stritly. Dependenies

that ould beenoded in the GE omponent may exist in the P omponent{

the advantage of this is that the implementor may hoose to update the GE

omponentonlywhenmostomputationallyonvenient.

5.2 Domain Operationsfor the GEPRepresentation

Meet Themeetof thepairsha

1

;f

1

iand ha

2

;f

2

ianbeomputedbyunifying

a 1

anda

2

and onatenatingf

1

andf

2 .

Renaming The objetsthat requirerenamingare formulaeand all(answer)

pattern GEP pairs. If adynami database is used to storethe pairs, then

re-naming isautomatially appliedeah timeapairislooked-upin thedatabase.

Formulaean berenamedwithasingleallto thePrologbuiltinopyterm.

Entailment Entailment heking works on three levels eah alled under a

negationsoasnotprodueanyproblematibindings.Therstentailmenthek

operatesonlyontheGEomponent(andisomplete forthisomponent).

En-tailmentofthefuntions enodedin theGEomponentisdenoteda

1

j=a

2

.To

testthis,bindeahdistintvariableina

1

toadistintgroundonstant,resulting

ina

0 1

.If,afterthishasbeenperformed,a

0 1

maybeuniedwitha

2

,thena

1

j=a

2 .

Otherwisea

1

6j=a

2

.Theseondentailmenthekisonlyappliedtoformulainthe

Pomponent.Thisimplementsthe(inomplete)entailslite algorithmdesribed

in setion 4.3.Thepropagating proessesare realisedusing blok delarations.

Asinglepassovertheformulaesetsuptheproessandeahlauseresultsintwo

proessesatanyonetime.Theostofsuspendingandresumingtheseproesses

(11)

thatifanyoftheoriginalvariableshaveproessesblokedonthem,thenthenew

variableswillhaveopiesoftheproessesblokedonthem.Thissavesrepeating

workintheallstoentailslite.

Projetion Projetionis only applied to formulae in the P omponent. It is

performedusingthealgorithmgiveninsetion4.4.Clausesproduedby

proje-tionthat areequivalenttotrue (thatis,the intersetionof theheadandbody

variablesisnonempty)areimmediatelydisarded.Theompationstepisbased

ontheentailslitealgorithm.However,asthepurposeofompationistoprevent

an explosion in thesize of the representation,ompation isonly performedif

therepresentationaftersyllogisingislargerthanbeforehand.Sineentailslite is

inompletesomeredundantlausesmayberetained,howeverthis ismorethan

ompensatedbythereduedomplexityofompation.

Join Calulatingthejoinofthepairsha

1

;f

1

iandha

2

;f

2

iisompliatedbythe

waythat joininteratswithrenaming.Speially, inanon-ground

representa-tion,all(answer) patternswouldbetypiallystoredinadynamidatabaseso

that var(a

1

)\var(a

2

)=;.Heneha

1

;f

1

i(orequivalentlyha

2

;f

2

i)haveto be

appropriatelyrenamedbeforethejoinisalulated.Thisisahievedasfollows.

Plotkin's anti-uniation algorithm [22℄ is used to ompute the most spei

atom a that generalises a

1

and a

2

. (But observethat ifa

1

j=a

2

, a

2

is amost

spei generalisation of the atoms.) The basi idea is to reformulate a

1 asa pair ha 0 1 ;f 0 1

i whih satises two properties: a

0 1

is a syntati variant of a; the

pair representsthe samedependeny information asha

1

;truei. A pair ha

0 2 ;f 0 2 i reformulatinga 2

islikewiseonstruted.Theatomsa,a

0 1

anda

0 2

areuniedand

theformulaf

0 =(f 1 ^f 0 1

)_(f

2

^f

0 2

)isalulated.Thisalulationislteredby

entailmentheking.Iff

1

^f

0 1

j=f

2

^f

0 2

anbedetetedusingentailslite,then

f 0 =f 2 ^f 0 2

(andsymmetrially).Inthis asetheentailmentheksavesaall

tojoin(andtheassoiatedprojetion)andthereationofanewdata-struture,

f 0

. Otherwisethe join f

0

is omputedasin setion 4.1. Redundantlauses are

removedfromf

0

usingentailslite togivef,andtherebythejoinha;fi.

5.3 FixpointAlgorithms

Thegoal-dependentanalyserisdrivenbyaninduedmagibasediteration

strat-egy, rening that used in [19℄. Indued magi was introdued in [5℄, where a

meta-interpreter for semi-nave, goal-dependent, bottom-up evaluation is

pre-sented.Simpleoptimisationsansigniantlyimpatonperformane.In

parti-ular,as notedin [18℄,evaluationsresultingfromnewallsshould beperformed

beforethoseresultingfromnewanswers,andaalltosolveforoneruleshould

nish before another all to solvefor another rule starts. These optimisations

(12)

yser is based onsemi-nave iteration. Neitherof these analysers has exploited

ondensing[16,21℄.

6 Experimental Evaluation

Toassess the feasibility of multiheaded lauses as a representationof positive

Boolean funtions, the Pos-based groundness analyserswere tested on alarge

benhmarksuite.

BDDrepresentationsofBoolean funtionshavebeenpopularforthe

imple-mentationofPos-basedgroundnessanalysers.Forthisreasonananalyserusing

aBDD pakagehas also beeninstrumented. The BDD pakage available does

not employ aGER fatorisation. However,it should benoted that turning o

the GEP fatorisation with the multiheaded lause analyser does not greatly

aet itsperformane. This isastrength oflausal representations.An RCNF

analyser wasalso implemented in Prolog to aid the assessment of MHC. The

threegoal-dependentanalyserssharethesamexpointalgorithmandtherefore

runin lok-step.

Theanalysersareodedin SICStusProlog3.8.6with theexeptionforthe

domain operations for BDD-based Pos, whih were written in C by Shahte

[23℄,and ompiled withO2 levelof optimisation.Theanalysers were run ona

296MHzSunUltraSPARC-IIwith1GByteofRAMrunningSolaris7.Programs

are abstrated followingthe elegant (two program)sheme of [4℄to guarantee

orretness.Programsontainingdisjuntionsarenormalisedtodenitelauses.

Timeoutswereset attwominutes.

Table 1 presents the experimental results for the larger programs in the

benhmark suite. The olumns detail the following information, le: the

pro-gram name;size:thenumberofabstrat lauses;abs:thetimerequiretoread,

parse,normaliseandabstrattheprogram.Forgoal-dependentanalysisthe

x-pointtimesfortheMHC,RCNFandBDDanalysersaregiven,alongwithount:

thenumberofgroundargumentpositionsintheallandanswerpatternsfound

bytheanalyser.Forgoal-independentanalysis,thexpointtimesforMHCare

given,alongwiththenumberofgroundargumentsinthesuesspatterns.

Time-out is denoted by `{'. The goal-independent ounts are oasionallarger than

thegoal-dependentountsowingto thepresene ofodeunreahablefrom the

initialquery.

Multiheaded lauses perform onsistently better than RCNF for

goal-dependentanalysis.Thisisunsurprisinggiventheostofmeetandtherelative

expenseofequivalenehekingviadualBlakeanonialform,togetherwiththe

lteringapplied to join in MHC.MHComparesfavourablywith BDDs,

espe-iallyonsideringthat theBDD operationsexploit memoisationand areoded

in C. In terms of runtime, MHC and BDDs give similar results, although as

wouldbeexpeted,thedierentrepresentationsperformeddierentlyon

(13)

le size abs MHCRCNFBDDount MHCount

bridge.lpr 680.09 0.00 0.12 0.03 24 0.08 34

onman.pl 760.05 0.00 0.00 0.03 6 0.01 6

unify.pl 770.05 0.07 0.29 0.08 70 0.09 19

kalah.pl 780.05 0.02 0.11 0.04 199 0.02 42

nbody.pl 850.07 0.05 0.13 0.06 113 0.04 57

peep.pl 850.12 0.03 0.08 0.04 10 0.02 8

sdda.pl 890.06 0.04 0.07 0.05 17 0.02 4

bryant.pl 940.07 0.32 2.38 0.15 99 0.28 9

boyer.pl 950.08 0.05 0.07 0.04 3 0.02 5

read.pl 1010.09 0.05 0.23 0.08 99 0.03 37

qplan.pl 1080.09 0.03 0.25 0.07 216 0.05 27

trs.pl 1080.13 0.10 2.28 0.26 13 0.04 7

press.pl 1090.09 0.11 0.27 0.12 53 0.04 32

reduer.pl 1130.07 0.08 0.17 0.09 41 0.05 21

parserdg.pl 1220.09 0.09 0.29 0.08 43 0.04 24

simpleanalyzer.pl 1400.10 0.16 0.48 0.13 89 0.10 31

dbqas.pl 1430.09 0.03 0.04 0.04 18 0.03 24

ann.pl 1460.11 0.16 0.43 0.10 71 0.09 12

asm.pl 1600.17 0.05 0.19 0.09 90 0.14 16

nand.pl 1790.14 0.05 1.46 0.14 402 0.68 16

lnprolog.pl 2200.10 0.08 0.19 0.12 143 0.07 31

ili.pl 2210.15 0.55 1.63 0.13 4 0.15 5

strips.pl 2400.22 0.03 0.07 0.08 142 0.06 36

sim.pl 2440.22 1.09 24.78 0.25 100 0.62 33

rubik.pl 2550.21 0.22 25.32 0.20 158 0.16 51

hatparser.pl 2810.36 0.29 1.75 0.26 505 0.30 128

simv5-2.pl 2880.23 0.07 0.33 0.16 457 0.10 37

peval.pl 3320.18 0.64 4.62 0.16 27 1.30 17

airraft.pl 3950.54 0.15 0.70 0.41 687 0.12 196

essln.pl 5950.48 0.19 20.72 0.37 162 0.30 75

hat80.pl 8831.43 0.88 4.28 0.84 855 0.64 339

aqua.pl 39283.55 7.68 67.04 { 1285 6.59 458

Table1.TimingandPreisionResults

dependentandgoal-independentanalysis.Ofourse,anyPos-basedanalyseran

bebrokenusingtheshemafrom[6,14℄;theanalyserandealwiththearity14

aseof[6℄beforetimeout(thatis,asingleprediaterequiring16384iterations).

Themajorostin entailmentheking isinurred throughasesplittingin

entailsheavy.Instrumentationhasrevealedthatthetotalnumberoftimes

entail-slite is invokedin hekingF j=f almostneverexeedsjvar(F)j. Thereforein

pratieentailsheavy exhibitsubibehaviourinthesizeoftheinputformulae.

Furtherinstrumentationhasshownthatthemaximumnumberofheadsobserved

(14)

typiallydonot detet entailment,asthe vast majority of entailmentsare

de-tetedusing entailslite.Asdisentailmentisdemonstrated by thedisoveryofa

single ountermodel, thebinding of asmall number of variablesto theirvalue

in aountermodelisoftenenoughtogeneratetherestofthisountermodelvia

propagation.Thishelpstoexplainthesuessofthestratiedentailmenthek.

7 Related Work

TheeÆienyofgroundnessanalysisdependsonthewaydependeniesare

repre-sentedandimplemented.Therepresentationdeidesthealgorithmiomplexity

of the domain operations but the implementation an introdue a prohibitive

onstantfatoror evenpushtheomplexityintoahigherlass ifthere isnota

goodmathbetweentherepresentationandtheimplementationlanguage.

EÆ-ientBDD-basedPosanalysisareusuallyimplementedinlanguageswith

muta-ble data-struturessuhas C [24℄orSML [10,11℄.State-of-the-art BDD-based

groundnessanalysersemployaGEfatorisation[2℄whih keepssimpledenite

informationseparatefromdependenyinformation.Thisleadstoapartiularly

denserepresentation(meantinformally,asmallnumberofnodes/lausesinthe

representation)andisthereforeanimportantimplementation tati.

Thedensityoftherepresentationisasimportantto PrologasitistoC:the

densitydeterminesthesizeoftheinputstothedomainoperations,aswellas

im-patingonmemoryusage.ThedualBlakeanonialformrepresentationofDef

funtions[1,9℄isattrativeasitisamenabletoPrologimplementation[12℄and

itgivesauniquerepresentationforeveryDef funtion(up tovariableordered).

However,its requirementto maketransitivevariabledependeniesexpliitan

ompromisedensity.Forexample,thefuntion(x y)^(y z)isrepresented

as(x (y_z))^(y z).BeauseofthisHoweandKing[19℄ presenta

(non-orthogonal [1℄) lausal representation of Def as onjuntions of propositional

lauses,butdonotmaintainaanonialform.Thereforeentailmenthekingis

requiredtodetetstability.

Reently, Genaim and Codish [13℄ haveproposed adual representation for

Def.Forfuntion f,themodelsofoneg(f)arenamedand f isrepresentedby

a tuple reording for eah variable of f whih of these models the variable is

in. For example,the models of oneg(x !y) are ffx;yg;fxg;;g. Naming the

threemodelsa,b,respetively,f isrepresentedbyhab;ai.Thisrepresentation

leverly allows ACI1 uniation theory to be used for the domain operations

and elegantlysupports a GEfatorisation. Promising experimental results are

reported[13℄,butawideningisrequiredto analysetheaqua benhmark.

CodishandDemoen[7℄desribeamodelbasedPrologimplementation

teh-niqueforPosthatwouldenodex

1

$(x

2

^x

3

)asthreetupleshtrue;true;truei,

hfalse; ;falsei, hfalse;false; i. The tehnique performs well against

BDD-based Pos analysis of its era [24℄ but it doesnot sale smoothly to the larger

benhmarks.Heatonetal.[17℄thereforeproposeEPos,asub-domainofDef,that

(15)

the GE fatorisation.Themain nding of [17℄ is that this sub-domain retains

reasonablypreisionforgoal-dependentanalysisandpossessesgoodsaling

be-haviour.

8 Conlusion

Positive Boolean funtions anbe naturally expressed asmultiheaded lauses

whiharestraightforwardtounderstand,manipulateandodeinProlog.

Multi-headedlauseshavebeenusedasthebasisforeÆientgoal-dependentand

goal-independent Pos-based groundness analysers. The key to the suess of these

analysersis theironstanttime meet andtheiruse ofentailment heking

su-intly and eÆiently oded using blok delarations. Entailment heking is

stratied sothat many entailments are deteted using a low omplexity

algo-rithm.Thefullexponentialalgorithmisonlyappliedwhenneessaryfor

detet-ingstability,andeventhenthenumberofasesplitsistypiallyverysmall.The

analysersdonotrequirewideningforanyofthe benhmarks; however,natural

wideningstoDefortoEPosareavailableifrequired[6,14℄.Thisworkillustrates

thesubtletyofhoosingarepresentationanditsassoiatedoperations,evenfor

a well known domain. Minor hanges to the representation an have a

signif-iant impat on performane if they aet frequently ourring operations. It

alsodemonstratestheeetiveness ofstratifying highomplexityoperationsto

avoid expensive omputation wheneverpossible. The intelligent appliation of

thesimpleentailmenthekingalgorithmistheheartoftheanalyserpresented

in thispaper.

Referenes

1. T. Armstrong, K. Marriott, P. Shahte, and H. Sndergaard. Two Classes of

Boolean FuntionsforDependenyAnalysis. Siene ofComputer Programming,

31(1):3{45, 1998.

2. R. Bagnara andP.Shahte. FatorizingEquivalent VariablePairs in

ROBDD-BasedImplementationsofPos. InSeventhInternationalConfereneonAlgebrai

MethodologyandSoftwareTehnology,volume1548ofLetureNotesinComputer

Siene,pages471{485.Springer-Verlag,1999.

3. P.Bigot, S.Debray,and K. Marriott. Understanding Finiteness Analysisusing

Abstrat Interpretation. In Joint International Conferene and Symposium on

LogiProgramming,pages735{749.MITPress,1992.

4. F.Bueno,D.Cabeza,M.Hermenegildo,andG.Puebla. GlobalAnalysisof

Stan-dardPrologPrograms. InEuropeanSymposiumonProgramming,volume1058of

Leture NotesinComputer Siene,pages108{124.Springer-Verlag,1996.

5. M. Codish. EÆient Goal Direted Bottom-up Evaluation of Logi Programs.

JournalofLogiProgramming,38(3):355{370,1999.

6. M. Codish. Worst-CaseGroundness Analysisusing Positive Boolean Funtions.

JournalofLogiProgramming,41(1):125{128,1999.

(16)

inLogiPrograms. ACMTransationsonProgrammingLanguages andSystems,

21(5):948{976, 1999.

9. P.Dart. OnDerivedDependeniesand ConnetedDatabases. Journal of Logi

Programming,11(1{2):163{188, 1991.

10. C. Feht. Abstrakte Interpretation logisher Programme: Theorie,

Implemen-tierung,Generierung. PhDthesis,UniversitatdesSaarlandes,1997.

11. C.FehtandH.Seidl.AFasterSolverforGeneralSystemsofEquations. Siene

of ComputerProgramming,35(2-3):137{162,1999.

12. M. Gara de la Banda, M. Hermenegildo, M. Bruynooghe, V. Dumortier,

G. Janssens, and W. Simoens. Global Analysis of Constraint Logi Programs.

ACMTransationsonProgrammingLanguagesandSystems,18(5):564{614,1996.

13. S.Genaimand M.Codish. TheDef-inite Approahto DependenyAnalysis. In

EuropeanSymposiumonProgramming,volume2028ofLetureNotesinComputer

Siene,pages417{32.Springer-Verlag,2001.

14. S.Genaim,J.M. Howe, andM. Codish. Worst-CaseGroundnessAnalysisusing

Denite Boolean Funtions. Theory and Pratie of Logi Programming, 2001.

Forthoming.

15. R. Giaobazzi, S. Debray, and G. Levi. Generalized Semantis and Abstrat

Interpretation for Constraint Logi Programs. Journal of Logi Programming,

25(3):191{247, 1995.

16. R. Giaobazzi and F. Sozzari. A Logial Model for Relational Abstrat

Do-mains. ACMTransations onProgramming LanguagesandSystems, 20(5):1067{

1109,1998.

17. A.Heaton,M.Abo-Zaed,M.Codish,andA.King. ASimplePolynomial

Ground-nessAnalysisforLogiPrograms.JournalofLogiProgramming,45(1{3):143{156,

2000.

18. M. Hermenegildo, G. Puebla, K.Marriot, and P.Stukey. InrementalAnalysis

ofConstraintLogiPrograms.ACMTransationonProgrammingLanguagesand

Systems, 22(2):187{223,2000.

19. J.M.HoweandA.King.ImplementingGroundnessAnalysiswithDeniteBoolean

Funtions. In European Symposium on Programming, volume 1782 of Leture

Notes in Computer Siene, pages 200{214. Springer-Verlag, 2000. Available at

http://www.s.uk.a.uk/pubs/2000/949/.

20. A.KingandL. Lu. A BakwardsAnalysisforConstraintLogiPrograms.

Teh-nialReport4-01,UniversityofKent,2001.

21. K.Marriott and H.Sndergaard. Preise andEÆient GroundnessAnalysisfor

LogiPrograms.ACMLettersonProgrammingLanguagesandSystems,2(4):181{

196, 1993.

22. G.Plotkin. ANoteonIndutiveGeneralisation. MahineIntelligene,5:153{163,

1970.

23. P.Shahte. Preise andEÆientStatiAnalysisofLogiPrograms. PhDthesis,

DepartmentofComputerSiene,TheUniversityofMelbourne,Australia,1999.

24. P. VanHentenryk, A. Cortesi, and B.Le Charlier. Evaluation of the Domain

Figure

table,orti�
ationue℄norfyfyfynotDefueariables_and
Fig.3:TheentailsheavyAlgorithm

References

Related documents

It shows that we can construct Boolean functions with better cryptographic properties, which gives the guidance for the design of Boolean functions to resist algebraic attack, and

Moreover, the other cryptographic properties of the Boolean functions (whether symmetric or not) that we consider here are not very good (these functions may be composed with

In this paper we analyze the combinatorial properties related to the Walsh spectra of rotation symmetric Boolean functions on even number of variables.. These results are then

Maitra, “Cryptographically significant Boolean functions: construction and analysis in terms of algebraic immunity,” In Workshop on Fast Software Encryption , FSE 2005, number 3557

In this short paper, we present an idempotent (interpreted as rotation symmetric Boolean function) with nonlinearity 16268 having 15 many zeroes in the Walsh spectrum,

[14] Dalai, D.K., Gupta, K.C., Maitra, S.: Cryptographically significant Boolean func- tions: construction and analysis in terms of algebraic immunity, Fast Software En-

Another class of even n -variable balanced Boolean functions [14], called Tang-Carlet functions, was also proved to have almost optimal resistance [15].. But for Booelan functions

Thanks to the combination of the Shannon, positive and negative Davio expansions as well as their bi-versions, BKFDDs can embrace the advantages of existing well-known