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.Ja arB.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-icatede nitionstobeproducedautomaticallyfromtypede nitionsorHornclauseskeletonsandrelatesomeexperiencesinusinghigher-orderprogramminginProlog.1MotivationInthelastfewyears,interestinsystematicmethodsfortheconstructionofPrologprogramshassigni cantlyincreased.See,forexample,Gegg-Harrison[GH95];PowerandSterling[PS90];Kirschenbaum,Michaylov,andSterling[KMS96];SterlingandYalcinalp[SY96];andVasconcelosandFuchs[VF95].Thesepapershavebuiltonprevious,less-systematicapproachestoPrologprogramming,implicitintextbooksandsharedcode.TheprogressionofapproacheswasdiscussedinNaishandSterling[NS98].Twoaudiencescanbene tfromsystematicapproaches:noviceprogram-merswhoneedguidancetocreatecodeofreasonablequalityandexperienced1programmerswhowanttoincreasetheirproductivity.Theneedsofthesetwogroupsarequitedi erent.Novicescanlearnmoreeasilyfromconcreteexam-plesanddonothavetheexperiencetorecognisepatternsandabstractions.Experiencedprogrammerscanbene tfromusinghigherlevelsofabstractioninpowerfultools.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.ThisleadstoaproposalforasetofsoftwaretoolstoautomaticallyproducePrologproceduresfromtypede nitions.Wedescribeaprototypeimple-mentationandrelateourinitialexperiencesusingthesetoolsandusingthehigher-orderprogrammingstylewithProlog.Thecurrentworkwassparkedbythechallengetousethehigher-orderapproachtoexplaina\complicatedprogram,theruleinterpreterdescribedinSection17.4ofthesecondeditionofTheArtofProlog(SterlingandShapiro[SS94]).Inexplainingtheprogram,anewmethodwasformulated:The nalprogramisbuiltaroundanoutputtyperatherthananinputtype.Inthispaperwegiveanotherexampleofthistechnique,usingadi erentinterpreter.Whathasemergedisabetterunderstandingofhowtypescandrivepro-gramdevelopment,andhowNaishandSterling'sviewsofsystematicprogramconstructionviastepwiseenhancementarecomplementary.Theworkrelatestorecent,excitingadvancementsinthefunctionalprogrammingcommunityconcerningshape,whichsetsourviewsonprogramdevelopmentinabroadercontext.Theseinsightshavepromptedthedevelopmentofprototypesoft-waretoolsforpartiallyautomatingcodingbasedontypesandskeletons.Thispaperdescribesourexper

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

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

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

×
保存成功