您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > Programming in Prolog
TheJournalofFunctionalandLogicProgrammingTheMITPressVolume2000,Article431March2000ISSN1080{5230.MITPressJournals,FiveCambridgeCenter,Cambridge,MA02142-1493,USA;(617)253-2889;journals-orders@mit.edu,journals-info@mit.edu.PublishedonearticleatatimeinLATEXsourceformontheInternet.Paginationvariesfromcopytocopy.Formoreinformationandotherarticlessee:flp/gopher.mit.edu(617)253-2864;journals-rights@mit.edu.TheJournalofFunctionalandLogicProgrammingisapeer-reviewedandelectronicallypublishedscholarlyjournalthatcoversabroadscopeoftopicsfromfunctionalandlogicprogramming.Inparticular,itfocusesontheintegrationofthefunctionalandthelogicparadigmsaswellastheircommonfoundations.Editor-in-Chief:G.LeviEditorialBoard:H.A¨t-KaciL.AugustssonCh.BrzoskaJ.DarlingtonY.GuoM.HagiyaM.HanusT.IdaJ.JaarB.JayaramanM.K¨ohlerA.KrallH.KuchenJ.LaunchburyJ.LloydA.MiddeldorpD.MillerJ.J.Moreno-NavarroL.NaishM.J.O'DonnellP.PadawitzC.PalamidessiF.PfenningD.PlaistedR.PlasmeijerU.ReddyM.Rodrguez-ArtalejoF.SilbermannP.VanHentenryckD.S.WarrenAreaEditorExecutiveBoard:M.M.T.ChakravartyA.HallmannH.C.R.LockR.LoogenA.M¨uckElectronicMail:jflp.request@ls5.informatik.uni-dortmund.deiiStepwiseEnhancementandHigher-OrderProgramminginPrologLeeNaishlee@cs.mu.oz.auLeonSterlingleon@cs.mu.oz.au31March2000AbstractThispaperpresentstwoviewsofstepwiseenhancement,oneapragmaticsyntax-basedapproachandtheotherasemanticapproachbasedonhigher-orderfunctionsandrelatingtoshapeandpolytyp-ism.Theapproachesareoutlined,andtheperhapssurprisinglycloserelationshipbetweenthetwodescribed.Bycombiningtheadvantagesofbothapproaches,itisshownhowmorecodeinbothfunctionalandlogicprogramminglanguagescanbeconstructedinasystematicway.Wedescribeaprototypesystemthatallowshigher-orderpred-icatedenitionstobeproducedautomaticallyfromtypedenitionsorHornclauseskeletonsandrelatesomeexperiencesinusinghigher-orderprogramminginProlog.1MotivationInthelastfewyears,interestinsystematicmethodsfortheconstructionofPrologprogramshassignicantlyincreased.See,forexample,Gegg-Harrison[GH95];PowerandSterling[PS90];Kirschenbaum,Michaylov,andSterling[KMS96];SterlingandYalcinalp[SY96];andVasconcelosandFuchs[VF95].Thesepapershavebuiltonprevious,less-systematicapproachestoPrologprogramming,implicitintextbooksandsharedcode.TheprogressionofapproacheswasdiscussedinNaishandSterling[NS98].Twoaudiencescanbenetfromsystematicapproaches:noviceprogram-merswhoneedguidancetocreatecodeofreasonablequalityandexperienced1programmerswhowanttoincreasetheirproductivity.Theneedsofthesetwogroupsarequitedierent.Novicescanlearnmoreeasilyfromconcreteexam-plesanddonothavetheexperiencetorecognisepatternsandabstractions.Experiencedprogrammerscanbenetfromusinghigherlevelsofabstractioninpowerfultools.Weclaimthatbothaudiencescanbeaddressedthroughthemethodofstepwiseenhancement.Thismethodcanbeexplaineddirectlyintermsofprogrammingtechniquesappliedtosimpleprogramsandcanbegivenamoretheoreticalbasisintermsofhigher-orderfunctions.Inthispaperwereviewstepwiseenhancement,sketchhowtocaptureanenhancementasahigher-orderfunctionadaptedfromfoldr,andthensketchhowindividualenhancementsarespecialisationsoftheparticularfoldrpredicate.Weshowhowthisiscloselyrelatedtothenewideasonshapeandpolytypismbeingdiscussedinthefunctionalprogrammingcommunity(seeJayandCockett[JC94];Jay[Jay95];Belle,Jay,andMoggi[BJM96];JeuringandJansson[JJ96];JanssonandJeuring[JJ97]).Wegoontogeneralisethisworkinseveralways,utilisingkeyfeaturesoflogicprogramming,suchasnondeter-minismandflexiblemodes,andweshowhowfoldlcanalsobeadapted.ThisleadstoaproposalforasetofsoftwaretoolstoautomaticallyproducePrologproceduresfromtypedenitions.Wedescribeaprototypeimple-mentationandrelateourinitialexperiencesusingthesetoolsandusingthehigher-orderprogrammingstylewithProlog.Thecurrentworkwassparkedbythechallengetousethehigher-orderapproachtoexplaina\complicatedprogram,theruleinterpreterdescribedinSection17.4ofthesecondeditionofTheArtofProlog(SterlingandShapiro[SS94]).Inexplainingtheprogram,anewmethodwasformulated:Thenalprogramisbuiltaroundanoutputtyperatherthananinputtype.Inthispaperwegiveanotherexampleofthistechnique,usingadierentinterpreter.Whathasemergedisabetterunderstandingofhowtypescandrivepro-gramdevelopment,andhowNaishandSterling'sviewsofsystematicprogramconstructionviastepwiseenhancementarecomplementary.Theworkrelatestorecent,excitingadvancementsinthefunctionalprogrammingcommunityconcerningshape,whichsetsourviewsonprogramdevelopmentinabroadercontext.Theseinsightshavepromptedthedevelopmentofprototypesoft-waretoolsforpartiallyautomatingcodingbasedontypesandskeletons.Thispaperdescribesourexper
本文标题:Programming in Prolog
链接地址:https://www.777doc.com/doc-1916943 .html