/
proceduraldebuggingtechniquesforProlog,basedontheboxmodel[19],arenotav proceduraldebuggingtechniquesforProlog,basedontheboxmodel[19],arenotav

proceduraldebuggingtechniquesforProlog,basedontheboxmodel[19],arenotav - PDF document

lois-ondreau
lois-ondreau . @lois-ondreau
Follow
391 views
Uploaded On 2016-06-28

proceduraldebuggingtechniquesforProlog,basedontheboxmodel[19],arenotav - PPT Presentation

aPrtcrightrecursive bPdtcdoublyrecursiveFig4Provenancegraphswithannotationsforpro lingPrtcandPdtcona5nodelineargraphPdtccausesmorerule ringsthanPrtcandalsoderivesfactsinmultiplewaysNumber ID: 381285

(a)Prtc:right-recursive (b)Pdtc:doubly-recursiveFig.4.Provenancegraphswithannotationsforpro lingPrtcandPdtcona5-nodelineargraph.Pdtccausesmorerule ringsthanPrtcandalsoderivesfactsinmultipleways.Number

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "proceduraldebuggingtechniquesforProlog,b..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

proceduraldebuggingtechniquesforProlog,basedontheboxmodel[19],arenotavailableinDatalog.Instead,newdebuggingtechniquesareneededthataresolelybasedonthedeclarativereadingofrules.Inthispaper,wedevelopsuchaframeworkfordeclarativedebuggingandlogicpro ling.LetM=P(I)bethemodelofPoninputI.BugsinP(orI)manifestthemselvesthroughunexpectedanswers(groundatoms)A2M,orexpectedbutmissingA=2M.ThekeyideaofourapproachistorewritePintoaprovenance-enrichedprogram^P,whichrecordsthederivationhistoryofM=P(I)inanextendedmodel^M=^P(I).AprovenancegraphGisthenextractedfrom^M,whichtheusercanexplorefurtherviaprede nedviewsandad-hocqueries.UseCasesOverview.GivenanIDBatomA,ourapproachallowstoanswerquestionssuchasthefollowing:WhatisthedatalineageofA,i.e.,thesetofEDBfactsthatwereusedinaderivationofA,andwhatistherulelineage,i.e.,thesetofrulesusedtoderiveA?Whenchasingabugortryingtolocateasourceofineciency,ausercanexplorefurtherdetails:WhatisthegraphstructureGAofallderivationsofA?WhatisthelengthofA,i.e.,ofshortestderivations,andwhatistheweight,i.e.,numberofsimplederivations(prooftrees)ofA?Foranotherexample,assumetheuserencounterstwo\suspicous"atomsAandB.ItiseasytocomputethecommonlineageGAB=GA\GBsharedbyAandB,orthelowestcommonancestorsofAandB,i.e.,therule ringsandgroundatomsthatoccur\closest"toAandBinGAB,thustriangulatingpossiblesourcesoferror,somewhatsimilartoideasusedindeltadebugging[22].SincenodesinGAareassociatedwithrelationsymbolsandrules,ausermightalsowanttocomputeotheraggregates,i.e.,notonlyatthelevelofGA(groundatomsand rings),butatthelevelof(non-ground)rulesandrelationsymbols,respectively.Throughthisschema-levelpro ling,ausercanquickly ndthehot(cold)spotsinP,e.g.,ruleshavingthemost(least)numberof rings.RunningExample.Figure1givesanoverviewusingaverysimpleexample:(a)depictsaninputgraphe,while(b)showsitstransitiveclosuretc:=e+.Thestructureandnumberofdistinctderivationsoftcatomsfrombaseedgesinecanbeverydi erent,e.g.,whencomparingtheright-recursivePtc(=Prtc)above,withleft-recursiveordoubly-recursivevariantsPltcorPdtc,respectively.TheprovenancegraphG(ortherelevantsubgraphGAG,givenagoalA)providescrucialinformationtoanswertheaboveusecases.Fig.1(c)showstheprovenancegraphforthecomputationoftcviaPrtcfromabove.Boxnodesrepresentrule rings,i.e.,individualapplicationsoftheimmediateconsequenceoperatorTP,andconnectallbodyatomstotheheadatomviaaunique ringnode.ForthedebuggoalA=tc(a;b)thesubgraphGA,capturingallpossiblederivationsofA,ishighlighted(through llednodesandboldedges).OverviewandContributions.Wepresentasimplemethodfordebuggingandlogicallypro lingaDatalogprogramPviaaprovenance-enrichedrewriting^P.Thekeyideaistoextractfromtheextendedmodel^MaprovenancegraphGwhichisthenqueried,analyzed,andvisualizedbytheuser.GivenadebuggoalA,relevantsubgraphsGAcanbeobtainedeasilyandfurtheranalyzedviaalibraryofcommondebugviewsandad-hocuserqueries.Atthecoreofourapproach (a)Prtc:right-recursive (b)Pdtc:doubly-recursiveFig.4.Provenancegraphswithannotationsforpro lingPrtcandPdtcona5-nodelineargraph.Pdtccausesmorerule ringsthanPrtcandalsoderivesfactsinmultipleways.Numbersdenotelen(F)(in ringnodes)andlen(A)(inatomnodes),respectively.length,i.e.,earliestpossiblederivationround.NotehowsomeatomnodesinthegraphforPdtcinFig.4(b)havemoreincomingedges(andderivations)thanthecorrespondingnodesinthePrtcvariantshowninFig.4(a).ComputingtheMaximumRound.Anothermeasureisthenumberofstates(TProunds),neededtoderiveallconclusions.FromtherewritingPS,wecansimplydeterminethe nalstate:MaxRound(MR):�MR=maxfS:g(S, , , )g.Thismeasureshowsanothercleardi erencebetweenPrtcandPdtc:WhilePrtcrequires10roundstocomputealltransitiveedgesinoursamplegraph,Pdtconlyneeds6rounds.Generally,thedoubly-recursivevariantrequiressigni cantlyfewerrounds,i.e.,logarithmicinthesizeofthelongestsimplepathinthegraphversuslinearfortheright-recursiveimplementation.CountingRederivations.Toanalyzethenumberofderivationsinmoredetail,wecanusetheStatelogrewritingPStoalsocapturetemporalsaspects.WitheachapplicationoftheTPoperator,somefactsmightberederived.Notethat,ifafactisderivedviadi erentvariablebindingsinthebodyofarule(ordi erent evaluationtechniquesspeci ctotheunderlyingDatalogengine.Indeed,parallelwiththedevelopmentofthemethod,wehaveimplementedtwoincarnationsofaGraph-basedProvenanceAnalyzerandDebugger,i.e.,prototypesGpad/dlvandGpad/lb,fordeclarativedebuggingwiththeDLV[12]andLogicBlox[14]engines,respectively.Bothprototypes\wrap"theunderlyingDatalogengine,andoutsourcesomeprocessingaspectstoahostlanguage.Forexample,Gpad/dlvusesSwi-Prolog[20]asa\glue"toautomate(1)rulerewritings,(2)invocationofDLV,followedby(3)resultpost-processing,and(4)resultvisualizationusingGraphviz.WeareactivelydevelopingGpadfurtherandplanapublicreleaseinthenearfuture.5RelatedWorkWorkondeclarativedebugging,inparticularintheformofalgorithmicdebugginggoesasfarbackasthe1980's[18,7].Algorithmicdebuggingisaninteractiveprocesswheretheuserisaskedtodi erentiatebetweentheactualmodelofthe(presumeablybuggy)programandtheuser'sintendedmodel.Basedontheuser'sinput,thesystemthentriestolocatethefaultyrulesinaninteractiveses-sion.Ourapproachdi ersinanumberofaspects.First,algorithmicdebuggingisusuallybasedonaspeci coperationalsemantics,i.e.,SLDNFresolution,atop-down,left-to-rightstrategywithbacktrackingandnegation-as-failure,whichdi erssigni cantlyfromthedeclarativeDatalogsemantics(cf.Section1).More-over,whileourapproachisapplicable,inprinciple,inaninteractiveway,thissuggestsatightercouplingbetweenthedebuggerandtheunderlyingruleen-gine.Incontrast,ourapproachanditsGpadimplementationsdonotrequiresuchtightcoupling,butinsteadtreattheruleengineasablackbox.Inthisway,debuggingbecomesapost-mortemanalysisoftheprovenance-enrichedmodel^M=^P(I)viasimpleyetpowerfulgraphqueriesandaggregations.Anotherapproach,morecloselyrelatedtoours,istheDatalogdebugger[3],developedfortheDESsystem.Unlikepriorwork,andsimilartoours,theydonotviewderivationsasSLDprooftrees,butratheruseacomputationgraph,similartoourlabeledprovenancegraph.Ourapproachdi ersinanumberofways,e.g.,ourrei cationofderivationsinalabeledgraphallowsustouseregularpathqueriestonavigatetheprovenancegraph,locate(least)commonancestorsofbuggyatoms,etc.Anotherdi erenceisouruseofStatelogforkeepingtrackofderivationrounds,whichfacilitatespro lingofthemodelcomputationovertime(per ringround,identifytherules red,thenumberof(re-)derivationsperatomorrelation,etc.)RecentrelatedworkalsoincludesworkontracevisualizationforASP[4],step-by-stepexecutionofASPprograms[15],andanintegrateddebuggingenvironmentforDLV[16].DebuggingandProvenance.Chiticariuetal.[5]presentatoolfordebuggingdatabaseschemamappings.Theyfocusonthecomputationofderivationroutesfromsourcefactstoatarget.Themethodincludesthecomputationofminimalroutes,similartoshortestderivationsinourgraph.However,theirapproach seemslessconducivetopro lingsince,e.g.,provenanceinformationon ringroundsisnotavailableintheirapproach.Thereisanintruiginglycloserelationshipbetweenprovenancesemirings,i.e.,provenancepolynomialsandformalpowerseries[8],andourlabeledprovenancegraphsG.ThesemiringprovenanceofatomAisrepresentedinthestructureofGA.Consider,e.g.,Figure2:thein-edgesofrule ringscorrespondtoalogicalconjunction\^",ormoreabstractly,theproductoperator\ "ofthesemiring.Similarly,out-edgesrepresentadisjunction\_",i.e.,anabstractsumoperator\",mirroringthefactthatatomsingeneralhavemultiplederivations.ItiseasytoseethatafactAhasanin nitenumberofderivations(prooftrees)i thereisacycleinGA:e.g.,thederivationofA=tc(a;b)inFigures1and2involvesacyclethroughtc(b,b),tc(c,b),viatwo ringsofr2.ThisalsoexplainsProlog'snon-termination(Section1),which\nicely"mirrorsthefactthattherearein nitelymanyprooftrees.Ontheotherhand,suchcyclesarenotproblematicintheoriginalDatalogevaluationofM=P(I)orinourextendedprovenancemodel^M=^P(I),bothofwhichcanbeshowntoconvergeinpolynomialtime.6ConclusionsWehavepresentedaframeworkfordeclarativedebuggingandpro lingofData-logprograms.ThekeyideaistorewriteaprogramPinto^P,whichrecordsthederivationhistoryofM=P(I)inanextendedmodel^M=^P(I).^Pisobtainedfromthreesimplerewritingsfor(1)recordingrule rings,(2)reifyingthoseintoalabeledgraph,while(3)keepingtrackofderivationroundsinthestyleofStatelog.Aftertherewrittenprogramisevaluated,theresultingprovenancegraphcanbequeriedandvisualizedfordebuggingandpro lingpurposes.Wehaveillustratedthedeclarativepro lingapproachbyanalyzingdi erent,logicallyequivalentversionsofthetransitiveclosureprogramPtc.Themeasuresobtainedthroughlogicpro lingcorrelatewithruntimemeasuresforalarge,real-worldexample.TwoprototypicalsystemsGpad/dlvandGpad/lbhavebeenimplemented,forDLVandLogicBlox,respectively;apublicreleaseisplannedforthenearfuture.WhilewehavepresentedourapproachforpositiveDatalogonly,itisnotdiculttoseehowitcanbeextended,e.g.,forwell-foundedDatalog.Indeed,theGpadprototypesalreadysupportthehandlingofwell-foundednegationthroughasimpleStatelogencoding[11,13].Acknowledgments.WorksupportedinpartbyNSFawardsOCI-0722079,IIS-1118088,andagiftfromLogicBlox,Inc.References[1]Abiteboul,S.,Hull,R.,Vianu,V.:FoundationsofDatabases.Addison-Wesley(1995)[2]Bancilhon,F.,Ramakrishnan,R.:AnAmateur'sIntroductiontoRecursiveQueryProcessingStrategies.In:ReadingsinDatabaseSystems.pp.507{555(1988)

Related Contents


Next Show more