您好,欢迎访问三七文档
1、UnderonsiderationforpubliationinTheoryandPratieofLogiProgramming1TransformationsofLogiProgramswithGoalsasArgumentsALBERTOPETTOROSSIDipartimentodiInformatia,SistemieProduzione,Universit adiRomaTorVergata,ViadelPolitenio1,I-00133Roma,Italy(e-mail:alberto.pettorossiuniroma2.it)MAURIZIOPROIETTIIASI-CNR,VialeManzoni30,I-00185Roma,Italy(e-mail:proiettiiasi.rm.nr.it)AbstratWeonsiderasimpleextensionoflogiprogrammingwherevariablesmayrangeovergoalsandgoalsmaybeargumentsofprediates.Inthislanguageweanwri。
2、telogiprogramswhihusegoalsasdata.Wegivepratialevidenethat,byexploitingthisapabilitywhentransformingprograms,weanimproveprogrameÆieny.Weproposeasetofprogramtransformationruleswhihextendthefamiliarunfoldingandfoldingrulesandallowustomanipulatelauseswithgoalswhihourasargu-mentsofprediates.Inordertoprovetheorretnessofthesetransformationrules,weformallyde netheoperationalsemantisofourextendedlogiprogramminglanguage.ThissemantisisasimplevariantofLD-resolution.Whensuitableonditionsaresatis edthissemant。
3、isagreeswithLD-resolutionand,thus,theprogramswritteninourextendedlanguageanberunbyordinaryPrologsystems.Ourtransformationrulesareshowntopreservetheoperationalsemantisandtermi-nation.KEYWORDS:programtransformation,unfold/foldtransformationrules,higherorderlogiprogramming,ontinuations1IntrodutionProgramtransformationisaverypowerfulandwidelyreognizedmethodologyforderivingprogramsfromspei ations.Therules+strategiesapproahtoprogramtransformationwasadvoatedinthe1970sbyBurstallandDarlington(1977)fordev。
4、eloping rstorderfuntionalprograms.SinethenBurstallandDarlington’sapproahhasbeenfollowedinavarietyoflanguageparadigms,inludinglogiallanguages(TamakiandSato1984)andhigherorderfuntionallanguages(Sands1996).Thedistintivefeatureoftherules+strategiesapproahisthatitallowsustoseparatetheonernofprovingtheorretnessofprogramswithrespettospei ationsfromtheonernofahievingomputationaleÆieny.Indeed,theorretnessofthederivedprogramsisensuredbytheuseofsemantispreservingtransformationrules,whereastheomputationaleÆ。
5、ienyisahievedthroughthe2A.PettorossiandM.Proiettiuseofsuitablestrategieswhihguidetheappliationoftherules.Thepreservationofthesemantisisprovedoneandforall,forsomegivensetsoftransformationrules,andifwerestritourselvestosuitablelassesofprograms,weanalsoguar-anteethee etivenessofthestrategiesforimprovingeÆieny.Inthispaperwewillarguethroughsomeexamples,thatasimpleextensionoflogiprogrammingmaygiveextrapowertotheprogramtransformationmethod-ologybasedonrulesandstrategies.Thisextensiononsistsinallowingth。
6、euseofvariableswhihrangeovergoals,alledgoalvariables,andtheuseofgoalswhihareargumentsofprediates,alledgoalarguments.Inthepratieoflogiprogrammingtheideaofhavinggoalvariablesandgoalargumentsisnotnovel.Thereadermaylook,forinstane,at(SterlingandShapiro1986;Warren1982).Goalvariablesandgoalargumentsanbeusedforexpress-ingthemeaningoflogialonnetivesandforwritingprogramsinaontinuationpassingstyle(TarauandBoyer1990;Wand1980)asthefollowingexampleshows.Example1ThefollowingprogramP1:F_GFF_GGexpressesthemeani。
7、ngoftheoronnetive.ThefollowingprogramP2:p([℄;Cont)Contp([XjXs℄;Cont)p(Xs;q(X;Cont))q(0;Cont)ContusesthegoalvariableContwhihdenotesaontinuation.Thegoalp(l;true)su-eedsinP2i thelistlonsistsof0’sonly. Programswithgoalvariablesandgoalarguments,suhasP1andP2intheaboveexample,arenotallowedbytheusual rstordersyntaxofHornlauses,wherevariablesannotourasatomsandprediatesymbolsaredistintfromfuntionsymbols.Nevertheless,theseprogramsanberunbyordinaryPrologsystemswhoseoperationalsemantisisbasedonLD-resolution,。
8、thatis,SLD-resolutionwiththeleftmostseletionrule.FortheoneptsofLD-resolution,LD-derivation,andLD-treethereadermayreferto(Apt1997)Theextensionoflogiprogrammingweonsiderinthispaper,allowsustowriteprogramswhihusegoalsasdata.Thisextensionturnsouttobeusefulforper-formingprogrammanipulationswhiharerequiredduringprogramtransformationandareotherwiseimpossible.Forinstane,wewillseethatbyusinggoalvariablesandgoalarguments,weareabletoperformgoalrearrangements(alsoalledgoalreorderingsin(Bossietal.1996))whiha。
9、reoftenrequiredforfolding,withouta etingprogramterminationandwithoutinreasingnondeterminism.Goalrearrangementisalongstandingissueinlogiprogramtransformation.Indeed,althoughtheunfold/foldtransformationrulesbyTamakiandSato(1984)preservetheleastHerbrandmodel,theymayrequiregoalrearrangementsandthus,theymaynotpreservetheoperationalsemantisbasedonLD-resolution.Moreover,goalrearrangementsmayinreasenondeterminismbyrequiringthatprediateallsTransformationsofLogiProgramswithGoalsasArguments3havetobeevaluat。
10、edbeforetheirargumentsaresuÆientlyinstantiated,andinmanyPrologsystems,insuÆientlyinstantiatedallsofbuilt-inprediatesmayauseerrorsatrun-time.In(BossiandCoo1994)ithasbeenprovedthatbyrul-ingoutgoalrearrangements,ifsomesuitableonditionshold,thentheunfolding,folding,andgoalreplaementtransformationrulespreservetheoperationalseman-tisoflogiprogramsbasedonLD-resolutionand,inpartiular,theserulespreserveuniversaltermination,thatis,the nitenessofallLD-derivations(Apt1997;VasakandPotter1986).But,unfortunatel。
本文标题:Under consideration for publication in Theory and
链接地址:https://www.777doc.com/doc-6132238 .html