Graph--Based Processing of Logic Programs

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Graph{BasedProcessingofLogicProgramsDietmarSeipelUniversityofTubingenSand13,D{72076Tubingen,Germanyseipel@informatik.uni-tuebingen.deAbstractAlotofpracticalrecursivelogicqueriestoadeductivedatabaseareexpressedbylinearrecursiveDatalogprogramswithexactlyonerecursiverule,so-calledlinearsirups.Wegiveacharacterizationofk-sidedlinearDatalogsirups{theconceptwasintroducedbyNaughtonin[22]{basedonagraphmodelandpresentanormalformtowhicheverylinearDatalogsirupcanbetransformed.NormalizedlinearDatalogsirupscanbedecomposedbyacountingtechniqueintoklower-dimensionallinearsirupswhichcanbeevaluatedinparallelbyveryecientqueryevaluationalgorithms.Forcertainsetsoflinearsirupsdeningthesameintensionalpredicatewecanalsoderiveadecompositionapproachfromthegraphmodel.Anothertechniquebasedontheprexesofcompiledexpansionstransformsasetofchainruleswithbinarypredicatesymbols,aso-calledCFGprogram,intoatransitiongraph.CommonsubexpressionsbetweendierentcompiledformulascanbedetectedbythegraphminimizationalgorithmofHumanandMoore,cf.[16].Theminimizedgraphisusedtoguidetheordered,complete,butnon-redundantevaluationoftheprogram.Theresultinginterformulaoptimizationisageneralizationofthewell-knownwavefronttechniques,whichuseintermediateresultsfromoneiterationinfollowingiterations.Keywords:deductivedatabases,queryoptimization,linearrecursion,chainrules,wavefronttechniques,countingtechniques1IntroductionDeductivedatabasesusepredicatecalculusasapowerful,declarativequerylanguagetoretrievedatafromrelationaldatabases.Aqueryisformulatedasalogicprogram{morepreciselyasetofdenitehornclauses{andaquerygoalgivenbyasingleatom.Thepossiblyrecursiveprogramisevaluatediterativelyinaset{orientedfashionbasedontheprimitiveoperationsofrelationalalgebra{selection,projection,join{whichcanbeexecutedecientlyondatabases.Wavefronttechniques,cf.HanandLu[13],considerthecompletebinding{passingbehaviourofalogicprogram.TheydealwiththeexpansionofaprogramLPw.r.t.aquerygoalG,whichisgivenbyan(innite)sequenceofconjunctionsofatoms{eachconjunctioncalledastring{derivedviarepeatedSLD{resolutionbeginningwithgoalG.Thestringsarepartitionedinto1specialsubsetsof(transitively)connectedatomswhichareevaluatedseparately.SubsequentlytherelationsfortheintensionalpredicatesinLParecomposed.Wederiveoptimizationconceptsforprogramswithonerecursiverulebyinvestigatingtheques-tionhowtopartitionthestringsintoso{calledwavessuchthat(i)theresultofawaveinonestringisusefulforderivingtheresultsofrelatedwavesinotherstrings(multiplequeryoptimization),(ii)theintermediatewave{resultsformasuitabledecompositionofthenalresult.Foralinearrecursiverulewedeneagraph{representation,theaugmentedsubstitutiongraph,whichreectsthevariablesharingwithintherule.Thereisonenodeforeachargumentpositionoftheintensionalatomsandonenodeforeachextensionalatom.Theedgesconnectthosenodesthatsharevariables.Weshowhowthisgraphdescribesthegrowthofthewavesandhowtherulecanbedecomposedintoanitenumberofcertainlesscomplexlinearrecursiverules.Thisgeneralizesthecountingtechnique,cf.[2],fromlinearDatalogsirupsinlinearvariablepatterntoarbitrarylinearDatalogsirups.Note,thatthegeneralcountingtechniquesof[26],[27]donotidentifythewaves{theiremphasisisonthepropagationofquerybindings.Forasetoflinearrecursiverulesdeningthesameintensionalpredicateandhavingonlyunaryandbinaryextensionalpredicatesymbolswecanalsoderiveadecompositionapproachfromthesetoftheiraugmentedsubstitutiongraphs.ThereareseveralapproachesforprocessingrecursiveCFGprograms,e.g.themulti{formulamergedprocessingofHanandHenschen[12].Thisstack{directedprocessingalgorithmforbilinearCFGsirupsgeneratesmanysimilarstrings,whoseprocessingcanbeoptimizedbysharingandmergingoftheformulas.CFGprogramsarerelatedtocontext{freelanguages.Someexpressivenessresultsforthemaregivenin[8].TheapproachforgeneralCFGprogramspresentedhereisbasedonideasfromautomatatheoryandformallanguages.Thestringsareprocessedbyanalgorithmoperatingontheircorrespond-ingtransitiongraph,whichhasanodeforeachstring{prexandanedgefromeachnodetoitsdirectsuxes.Thus,severaltypesofredundancyintheprocessingofthestringscanbeavoided.ThereisasimilarrewritingtechniqueofHoutsmaandApers,cf.[17],whichisalsograph{based,butisonlyapplicableforregularmutuallyrecursivelogicprograms.1.1BasicDenitionsandNotationsSyntactically,adeductivedatabaseDDB=(DB;LP)isgivenbyasetDBoffacts,whichresemblearelationaldatabase,andalogicprogramLP,whichconsistsofasetofrulesforderivingnewfactsfromDB,cf.[21].Afactisanatomp(t1;:::;tn),wheretiisatermovervariables,constantsandfunctionsymbols.Agoalisgivenbyasequenceofatoms.Arulerisgivenbyr:p0(X0):p1(X1);:::;pn(Xn):wheretheatomp0(X0)iscalleditsheadandthegoalp1(X1);:::;pn(Xn)wheren2IN0iscalleditsbody.risaDatalogrule,iitcontainsnofunctionsymbolsinthetermsofitsatoms.2ThesemanticsofadeductivedatabaseDDB=(DB;LP)isdenedaccordingtothebottom-upornaiveevaluationalgorithms,cf.[3].Notionsofequivalenceforlogicprogramsareintroducedin[25].(i)Apredicatesymbolpisintensional,iitoccursintheheadofaruler2LP;otherwiseitisextensional.AlogicdatabaseDBisexte

1 / 25
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功