Improvements in program synthesis using fine-grain

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

IFIPWG2.1,WorkingConf.onConstructingProgramsfromSpecications,May91,PacicGrove/CAImprovementsinProgramSynthesisUsingFine-GrainSortedLogicyJochenBurghardtGMDForschungsstelleanderUniversitatKarlsruhe(GermanNationalResearchCenterforComputerScience)Vincenz-Prienitz-Strae1,D-7500KarlsruheTel.:*49-721-662245E-Mail:burghard@gmdka.uucpAbstract:Thispaperintroducesanewconstructor-basedsortdisciplineonpredicatelogicwhichallowstoexpressmoresophisticatedsortsthanconventionalapproaches.Algorithmsaregiventocalculateinmumanddierenceoftwosortsandtodecidethesubsortandtheequivalenceproperty.Therangesortofadenedfunctioniscalculatedfromitsdeningequations,leadingtoamoreexactdescriptionthanobtainingasignaturefromtheuser:dierentequationsareusuallyassigneddierentsorts.Thus,thesortdisciplinehelpstoselectthe\rightequationsforinferencesteps,andcutsdownthesearchspaceofaformalproof.Thiseectisdemonstratedusinganexamplefromtheareaofdatarenementandimplementationproofs.1IntroductionThegrowingneedforhighqualitysoftwarerequiresmoreandmoretheapplicationoffor-malprogramdevelopmentmethods.Variousapproachestothisareaareknown,requiringformalproofsinoneoranothermathematicalframework.OneofthemainproblemscommontotheseapproachesistheenourmousextraexpenserequiredtoperformlotsofmostlytrivialproofstepsthatmakescomputersupportnecessarytondproofsatleastyThisworkwaspartiallyfundedbytheBMFTprojectKorso,contractnumberITS9001A7.forsimplesubproblems.Itisawellknownexperiencethatevenforsuchsimplesubproblemsitishardandoftenimpossibletondsolutionsautomaticallybybruteforce(topdown)search.Instead,thesuccessofmanyformalprogramdevelopmentmethodsseemstobebasedonakindof(bottomup)preparationofthe\domainofdiscourseinordertogainsomeknowledgethatcanactpartlyasasubstitutefortheintuitionofahumanprover.Finance[Fin88],forexample,usesdataowanalysisontheaxiomsandgoalsinordertodirectHornclauseresolution.Bird[Bir86]usestheformationofalgebraic(homomorphic)lawstoavoidinductioninhisproofs;thenecessaryinductionsaremostlypartofthepreparationofaspecicdomainandcanoftenbedoneonceandforall.MannaandWaldingeruseorderingrelationsandmonotonicfunctionsasaproofguidingprinciple[MaWa86,Tra89].Inthispaper,asortdisciplineisintroducedforthesamepurposeof\preparingadomain.Themoreexpressiveasortdisciplineis,themoreinformationcanbestatedintermsofsortsratherthanofformulasandthusthemoreworkcanbeshiftedfromageneralpurposetheoremprovertospecialsuitedsortcheckalgorithms.Employinganorder-sorteddiscipline,consistingofapartiallyorderednitesetofsorts,hasturnedouttoenablearesolutionprovertosolveSchubert’ssteamrollerproblem[Wal85].Recentworkcombinesorder-sortednesswiththemeansofparametricpolymor-phism[Smo89],allowingamoresophisticatedsorthierarchyduetothemonotonicityofthesortconstructors.Inconventionalapproaches,dataconstructors(likecons(x;l))arestrictlydistinguishedfromsortconstructors(likelist()).Inthispaper,ane-grainsortdisciplineisdescribedthatisbasedonviewingeachdataconstructoralsoasasortconstructor.Asaconse-quence,therecanbeinnitechainsofsortinclusions(like:::s(s(nat))s(nat)nat)whichareforbiddeneveninSmolka’sframework[Smo89];sorttermscanbearbitrarycomplex,reectingthecomplexityofdatatermsthatcanoccurduringaproof.Thus,thesortofadatatermcanbedescribedmoreprecisely.Analgorithmforcalculatingtheinmumoftwosortsispresentedthatdynamicallycreatesanewrecursivedenitionoftheinmumsort.Forexample,theevennumbersandthenaturalnumbersdivisiblebythreecanbeexpressedassortsandtheirinmumiscalculatedasthesortofnaturalnumbersdivisiblebysix.Analogously,analgorithmforcalculatingthedierenceoftwosortsisgivenwhichservesasabasisfordecidingthesubsortpropertyandhencetheequivalenceoftwosorts.Therangesortofanon-constructorfunctioniscalculatedfromitsdeningequationsratherthanbeinggivenbyadeclaration.Sortcalculationallowstodeterminetherangesortsdependingonthedomainsortsmoreprecisely,assertingpossiblydierentsortstotherighthandsidesofdierentdeningequations.Thus,equationscanbeselectedordiscardedforanactualinferencestepbyreasoningaboutsorts.Analgorithmforcalculatingtherangesortofafunctionisgiven.Thesortcalculationalgorithmsaredemonstratedusinganexamplefromtheprogramsynthesisarea,showingtheeectofsearchspacereduction.Afteramotivatingexampleinsection2andthedenitionofsyntaxandsemanticsofasortsysteminsection3,weintroducethemainalgorithmsinsections4through7.Insection8nally,weresumetheexamplefromsection2andshowhowthesortalgorithmscanbeusedtoguideprogramsynthesis.Afullversionincludingallproofscanbeobtainedfromtheauthor.2MotivationConsiderthefollowingexamplefromtheareaofformalprogramdevelopment.Weusethemethodofdatarenement(cf.forexample[Gri81,Ehr80,Nei87])tondanimplementationofnaturalnumberswhichisclosetotheecientrepresentationbybinarystringsusedincomputerhardware.WehavethesortofnaturalnumbersinPeanoformandthesortoflistsofbinarydigitsinreversenotation(\:=denotessortdenition,\jdenotestheunionofsorts):nat:=0js(nat)bin:=niljo(bin)ji(bin)Furthermore,wehaveaxiomsdeningtherepresentationfunctionvalfrombintonatandanauxiliaryfunct

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

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

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

×
保存成功