您好,欢迎访问三七文档
TechnischeUniversit¨atBerlinForschungsberichtedesFachbereichsInformatikOntheSemanticsofaConcurrencyMonadwithChoiceandServicesThomasFrauensteinWolfgangGrieskampMarioS udholtReportNo.96{14RevisedVersion,July1996TechnischeUniversit¨atBerlinFachbereich13 InformatikFranklinstraße28/29 D-10587BerlinOntheSemanticsofaConcurrencyMonadwithChoiceandServicesThomasFrauenstein,WolfgangGrieskampandMarioS udholtTechnischeUniversit atBerlin,FachbereichInformatik,Sekr.FR5-13,Franklinstr.28/29,10587Berlin,e-mail:fthofra,wg,fishg@cs.tu-berlin.deAbstractWedeveloptwosemanticsfortheconcurrencymonadofthepurelyfunctionallanguageOpal,whichprovidesageneralmonadicchoice,value-resultagentsandguardedclient-serverbasedcommunication.Thetransitionsemanticssupportsanoperationalunderstandingoftheconcurrencymonad.Thestate-transformerseman-ticsgivesanaxiomaticdescriptionoftheconcurrencymonadbyusingavariantoftemporalintervallogicassyntacticsugarontopofLCF.Inordertocopewithtypingproblemsinbothsemantics,amodi ednotionofdynamictypesisdeveloped,whichentailsasaspecialcaselocalexistentialquanti cationoftypevariablesinconstructorfunctions.Note:Thisversion(revisedversion,July1996)ofTR96-14di ersfromtheprintedversiondatedMay1996inthatpartsofthestate-transformersemantics(Section5)havebeenrevised.CONTENTS2Contents1Introduction32TheKernelLanguage42.1Syntax......................................42.2OperationalSemantics.............................72.3LCF-StyleDenotationalSemantics......................73TheConcurrencyMonad84TransitionSemantics104.1ExtendingtheConcurrencyMonad......................104.2TheConcurrentTransitionSemantics.....................115State-TransformerSemantics135.1TheState....................................135.2RepresentingCommands............................145.3TemporalObservations.............................145.4AxiomatizationoftheConcurrencyMonad..................166RelatedandFutureWork187Conclusion201INTRODUCTION31IntroductionMuchhasbeensaidaboutthesuitabilityoffunctionallanguagesforthedesignandimple-mentationofalgorithms:theirelegance,mathematicalclarity,transparencyandveri abil-ityhavebeenpositivelynoticed.ButfunctionallanguagesarealsoconsideredtohaveanAchille’sheel:thehandlingofinput/outputand|moregenerally|programmingwithsidee ectshas(atleast)beenclumsy.Variousapproacheshavebeenstudiedovertheyearsine ortstoovercomethisde- ciency,notablystream-processingfunctions,continuationsandmonads.Thiswork,inparticularthatfocusingonthemonadicapproach,hasledtosomesuccessinsequentialI/Osituations.Thetermimperativefunctionalprogramming[JW93]hasbeencoinedtonameastyleofprogrammingwherecomputationsexhibitingside-e ectsarerepresentedasvaluesofamonadictype.Theyareconstructedandtransformedinapurelyfunctionalstyleandinterpretedasfunctionstransformingaglobalstate{inthecaseofanI/Omonad,the\state-of-the-world.ConcurrentextensionsoftheusualI/OmonadfoundinlanguagessuchasHaskellandOpalhaverecentlybeendesigned,implementedandsuccessfullyapplied,e.g.totheconstructionofgraphicaluserinterfaces[FGPS96,JGF96,FJ95].TheseextensionsraisethequestionofanadequatesemanticmodelofI/Omonadsinthepresenceofindetermin-isticcomputations.Whilethe\state-of-the-worldparadigmforconventionalI/Omonadshasalreadybeenthesubjectofjusti edcriticismbecauseitstreatmentoftheunpredictablebehaviourofI/Ooperationsissomewhat\magical,itsapplicationtoexplicitconcurrentprogrammingraisesevenmorequestions.Inthispaperwepresenttwosemanticmodelsoftheconcurrencymonadofthepurelyfunctionalprogrammingandspeci cationlanguageOpal[DFG+94].Theconcurrencymonadprovidesamonadicchoice,value-resultagentsandguardedclient-servercommuni-cation.IthasbeenimplementedintheOpalsystemandusedtorealizeacomprehensivegraphicaluserinterfacelibrary[FGPS96].Here,wedevelopanoperationaltransitionse-manticsandanaxiomaticstate-transformersemanticsfortheconcurrencymonad,thathandleindeterminismexplicitly.Thetransitionsemanticsde nesmonadicvaluesastermsofaparticularfreetypethatareconstructedinadeterministicfunctionalwayanddeconstructedinanindeterministicconcurrentway.Thistreatmentre ectsthecleardistinctionbetweentheworldof -reductionandthatofconcurrentexecution.Incontrast,thestate-transformersemanticspreservestheviewofmonadsasfunctionstransformingaglobalstate:however,indeter-minismismodelledbyassociatingalooseclassofpossibleinterpretationswitheachstatetransformer.Thistreatmentisnotconstructive;itspurposeistoprovideaframeworkforalgebraic-axiomaticspeci cationandreasoningaboutconcurrentmonadicprogramswhichistechnicallysupportedbyavariantofinterval-basedtemporallogicde nedassyntacticsugarontopofanLCF-likelogic.Inordertoovercomerestrictionsonthetypesystemofthesimplytypedpolymorphic -calculuswhichhinderaformulationofoursemantics,wedevelopamodi ednotionofdynamictypesthatallowsustohaveunboundtypevariablesinthedomainofconstructor2THEKERNELLANGUAGE4functions.Althoughwedonotneedthefullpowerofthiskindofdynamics|weonlyusethemtomodellocalexistentialquanti cation|wehavepreferredthisapproachbecauseofitssimplicityandwell-foundnessduetotheworkof[ACPP8
本文标题:On the semantics of a concurrency monad with choic
链接地址:https://www.777doc.com/doc-5353717 .html