您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > Bisimulation in Functional Programming
ProvingCongruenceofBisimulationinFunctionalProgrammingLanguagesDouglasJ.HoweAT&TBellLaboratories600MountainAvenue,Room2B-438MurrayHill,NJ07974,USAhowe@research.att.comiProvingCongruenceofBisimulationDouglasJ.HoweAT&TBellLaboratories600MountainAvenue,Room2B-438MurrayHill,NJ07974,USAhowe@research.att.comiiAbstractWegiveamethodforprovingcongruenceofbisimulation-likeequivalencesinfunc-tionalprogramminglanguages.Themethodappliestolanguagesthatcanbepresentedasasetofexpressionstogetherwithanevaluationrelation.WeusethismethodtoshowthatsomegeneralizationsofAbramsky’sapplicativebisimulationarecongruenceswheneverevaluationcanbespeci edbyacertainnaturalformofstructuredopera-tionalsemantics.Oneofthegeneralizationshandlesnondeterminismanddivergingcomputations.iiiProvingCongruenceofBisimulationinFunctionalProgrammingLanguagesDouglasJ.HoweAT&TBellLaboratories600MountainAvenue,Room2B-438MurrayHill,NJ07974,USAhowe@research.att.comAbstractWegiveamethodforprovingcongruenceofbisimulation-likeequivalencesinfunc-tionalprogramminglanguages.Themethodappliestolanguagesthatcanbepresentedasasetofexpressionstogetherwithanevaluationrelation.WeusethismethodtoshowthatsomegeneralizationsofAbramsky’sapplicativebisimulationarecongruenceswheneverevaluationcanbespeci edbyacertainnaturalformofstructuredopera-tionalsemantics.Oneofthegeneralizationshandlesnondeterminismanddivergingcomputations.1IntroductionOnewaytoviewafunctionalprogramminglanguageisasanevaluationsystem,whichwede netobeasetoftermstogetherwithanevaluationrelation.Theintentionisthatatermaevaluatestoanothertermv,writtena)v,ifthereisacomputationstartingwithathatterminateswithresultv.Programequivalenceiscentraltoreasoningaboutfunctionalprograms.Thequestionarisesofwhentwoprogramsinanevaluationsystemaretobeconsideredequivalent.Therearetwopropertiesonemightexpectforareasonableequivalence,atleastwhencomputa-tionisdeterministic.First,iftwoprogramsareequivalentandevaluationofoneofthemterminates(thatis,producesavalue),thensoshouldevaluationoftheother,andthetworesultingvaluesshouldbeequivalent.Second,iftwovaluesvandv0areequivalent,thentheyshouldbothbethesamekindofvalue,and,furthermore,thecomponentsofvandv0shouldbeequivalent.Forexample,ifv=hv1;v2ithenv0shouldbeapairhv01;v02iwithv1equivalenttov01andv2equivalenttov02.Thecasewherevandv0arefunctionsislessclear.Supposev= x:bandv0= x:b0.Inthecaseofthelazy -calculus,itispossibleforacomputationinvolvingvorv0tosubstitute1anytermwhatsoeverforx.Thusifvandv0areequivalent,thenforalltermse,b[e=x]andb0[e=x]shouldbeequivalent.Ifthesepropertiesaretakenasade nitionofprogramequivalence,theninthecaseofthelazy -calculuswegettheapplicativebisimulationofAbramsky1990.Thelazy -calculuscanbeviewedasanevaluationsystemE bytakingthefollowingtworulesasaninductivede nitionofevaluation.f) x:bb[a=x])cf(a))c x:b) x:bApplicativebisimulationcannowbede nedasthesymmetricclosureofthelargestbinaryrelation overclosedtermssuchthatifa a0anda) x:bthenthereisab0suchthata0) x:b0andforallclosede,b[e=x] b0[e=x].Anequivalentformulation,whichismoresuggestiveofthename\applicativebisimulation,isthefollowing.Saythataconvergesifthereisacsuchthata)c.Then isthelargestrelationonclosedtermssuchthatifa a0andaconvergesthena0convergesandforallclosede,a(e) a0(e).Usingthisde nitionitistrivialtoverify,forexample,that( x:b)(a) b[a=x],sinceifonesideevaluatestosomevalue,thentheothersideevaluatestothesamevalue.However,inorderforbisimulationtobeausefulprogramequivalence,weneedtobeabletosubstituteequalsforequals.Wecandothisbecausebisimulationisacongruence:ifa bandC[ ]isacontext(atermwithahole)thenC[a] C[b].ThiscanbeprovedusingatechniquefromBerry1981.Thebasicideaistoshowthattwotermsarebisimilarifandonlyiftheyareobservationallycongruent,inthesensethatreplacingonebytheotherinanycontextpreservesobservableresultsofevaluation.ForE ,theobservableresultofevaluatingatermissimplythefactthatthetermhasavalue,andsoaandbareobservationallycongruentifandonlyifforallcontextsC[ ],C[a]convergesandonlyifC[b]does.SimilarproofshavebeendoneformorecomplicatedlanguagesthanE .Theproofsarenotparticularlydi cult,buttheyarealldonefrom rstprinciplesandinvolvedetailedanalysisofthereductionoftermsthatinvolvecontexts.See,forexample,Talcott1985,Bloom1990andJagadeesan1991.Thispapermakestwomaincontributions.The rstisasimplerandmoregeneralmethodforprovingcongruenceofbisimulation-likeequivalencesforevaluationsystems.Itismoregeneralbecauseitdoesnotrequirebisimulationtobethesameassomeformofobservationalcongruencetowhichtheknowntechniquescanbeapplied.Itissimplerbecauseiteliminatesreasoningaboutcontextsandbecausemostoftheworkinapplyingittoparticularevaluationsystemsandsimulationscanbefactoredoutandcapturedinsomesimpletechnicallemmas.Thesecondcontributionisaformalismforspecifyingevaluationrelationsthatguaranteesthatcertainbisimulation-likeequivalencesarecongruences.ThisformalismisinthegeneralspiritofPlotkin1981andthe\naturalsemanticsofKahn1987.Anevaluationsystemwhoseevaluationcanbede nedusingthisformalismiscalledastructuredevaluationsystem.Section2de nes
本文标题:Bisimulation in Functional Programming
链接地址:https://www.777doc.com/doc-5517818 .html