; TeX output 1996.03.06:1228so0GGdcr1728Theh'LGGdctt1728semantic-pacykage!", cmsy1086e dcr1200PweterlMllerNeergaard]L dctt1200turtle@diku.dkhttp://www.diku.dk/students/turtle%vVMarcwhl6,1996-bލ"!l dcbx0900Abstract_ o$  dcr0900Thispac dcbx10001WSym>bQolsmڬ2`I2WInferenceRulesI33T ranslationDiagrams+C4`4SomeNotesabQouttheFiles t6̍ILcK"ȜI&&oi dctt1000semantic " dcr1000isaLf'hdcr0700AzTUY&E9X2 b> cmmi10"+M/-packqageeasy IinghthewritingofnotationofsemanItics!andcompilers.׀T*ouseittheIleDsemantic.styshouldbGeplaced,Iso'thatLfAzTUY&E9Xcanndit. InyourIdoGcument!preambleyoushouldincludeI\usepackage{semantic}XInVthefollowingIwilldescribGetheIuse?ofthedierentpartsofOsemantic:IsymbGols,inferencerulesandtranslaItionOMdiagrams.`ThereisalsoasectionIdescribingtheinstallationandgivingIa shortintroGductiontothetwolesIsemantic.dtxU andsemantic.ins.XLikedQmostothercomputer-programs,IIm#havemkprovidedthispackqagewithsevIeralAbugs,N},whichyieldsICW[[h*y dcit1000commandVi.A(]]ahenvir}/onmentɸiy.$If}youneedtodescribGemorethanonekindofevqalIuations,e.g.bGothE!andE^ O!cmsy7}ܹ,youcanprovideanoptionalargumentimmediatelyIafter2\comprespGectively\eval.AsanexampleadenotationalruleforasequenIciliasingU oftwoU commandssEICW[[C1?;C2]]{+Iand=>, whichisavqailableinbGothmathematicsandtext.ZBytypinga*or+afterI->U or=>yougetthestarred*handplussedversions:q!^,)^,!^ٓRcmr7+ and)^+.XInT6theinferencesymbols-environmentT6thevqastma0jorityofLfAzTUY&E9X-commandsIworkṡnormally*.׶ItishowevernotpGossibletoensure,athatthesymbGols|,a-andI=works100%likeoutsidetheenvironment^1|2,Գandforinstance\cline{::: -:::}IcannotEbGeusedinthisenvironmentE(ithoweverEworksifitispartofacommandIdenedU outsidetheenvironment).I&ffr E !i-:0][dcr06001KInside6theenÒvironment61adctt0800|,N-and=aredenedasmacros.0Thesemacrosexamensthenext cÒharacter3andifitis-or=,KG>and>resp dccc1000TrZue+`s >0)^0 ;^0Q`while?E9dosF<)^00sSwfe (׍q`while?E9dosF<)^00 It(2)U :<#C]ڵ`E )Fhalse*b wfeu (׍`while?E9dosF<)퍑LU and𨍍荒εp,MU !^p^09,M^0 ;εp^09,M^0#Y!U p^00r,M^00JFwfeQp (׍Op,MU !^p^00r,M^00TUK cmsy8!-:wqAacmr61i2feF4E (׍p,MU !^p,MP^TU!-:wq2%LU areU easilysetusing\inference.qThesyntaxis31b\inference[5 cmsy9hnameiJ]{hline1*i\\\N45" cmmi9:::=B\\Nhline;cmmi6n7i}{hc$onclusion.i1}31Iwhere9n0soyoualsocantypGeaxioms.hpEachlineconsitsofpremisessepGerated IbyU &:bhpr$emise1*i*~&::: ʦ&hpr$emisemiINotethatmcanalsobGezerowhichisusedwhentypingaxioms.Theoptional InameU issettotherightoftheinference.XThe rulesissetsothelineushwiththecenterofsmalllettersinthesurroundIing~text.VInthisway~secondaryconditionsornames(liketherstexampleabGove)Ican.bGewritteninthesurroundingtext.@ItalsomakesitpossibletosettherulesIinU atablelikeshownherewiththelastexample:jwR^T*ransitiveU (1):荒p,MU !^p^09,M^0 ;p^09,M^0#Y!U p^00r,M^00lwfeQp (׍Op,MU !^p^00r,M^0044^T*ransitiveU (2):l2feF4E (׍p,MU !^p,M\vXAnU inferencerulecanunproblematiclybGenestedwithinanother,like:-N<#`n 9)feF4E (׍p,MU !^p,M=.xL!-:wq2p,MU !^p^09,M^0fwfe (׍;p,MU !^p^09,M^0byxL!-:wq1:6p^09,M'U !p^00r,M^00_ )wfe% (׍qEp,MU !^p^00r,M^00 {TU!-:wq1XThe"appGearanceoftheinferencesrulescanpartlybecontrolledbythefollowing$n\setpremisesend\setpremisesspace \setnamespaceIlengths:ȍ<#"=Kpremisesend Í<u cmex10z31Z}|31Z{premise"=premisesSpace Íz31 }|31 {'premise<wfe( (׍2`conclusion$Pnamespace Í)dz31 }|31 {GTUnamenIThelengthsarechangedusingthethreecommands\setnamespace{hlengthUi"Yx},I\setpremisesend{hlengthUi"Yx}[og\setpremisesspace{hlengthUi}.hlengthUi.:!canbGeIgiveninbGothabsoluteunitslikeptandcmandinrelativeunitslikeemandIex.xThe defaultvqaluesare:1 33133&fes2bemforpremisesspace, 3&fes4 emforpremisesendog J331J33&fes2ObemNfornamespace. Notethatthelengthsc}/annotbGealteredusingtheordinaryILfAzTUY&E9X-commandsU \setlengthand\addtolength.XBesides9thattheappGearanceofinferencerulesislikefractionsinmath:(AmongIother7NthingsthepremiseswillnormallybGeatsameheightabove7NthebaselineandIthereisaminimumdistancefromthelinetothebGottomofthepremises..TheIinformationU tosettheruleslikefractionistakenfromthecurrentmathfont.(3!PsodI8*= manfntUF:etcћkM dcsl0900expressionistobAeIev|yaluatedinaen#3#4\predicateend{%kr$#1N\vdash$\texttt{#2}$\stackrel{#3}{\Rightarrow}_S#4$} i IThenUtheinference(bAorro]vY) JSs-=0D`s>v7{q 0ncmsy50Y) JSs-=00֟Ife՟ ؝r9DӍ`NTl(s)>v7{q0Y) JSs-=00:saeTlRgIcan$bAeaccomplishedb{v}s'&D|-$s$=>{v'}s''}kr{DN|-Tl($s$)=>{v'}s''}i IPlease$notethattheinferencesymbols-en&examened,Xeandifitis\end,semanticconcludesthatthepremisedo,himplementationDplanguageiky} b\interpreter{hsour$cei ,himplemenationAlanguageih}b\compiler{hsour$cei ,hmachinei)d,htar$get+ie}b\machine{hmachinei)d}ITheZargumentscanbGeaeitherastringdescribingthelanguage(pleasedonotuse Ia3=macroatthestartofthestring)oroneofthefourcommands. However3=theIcombinations)givingnomeaningareexcludedlikeimplementingainterpreteronIaU program,whichyieldtheerrormessage:fP!NPackagesemanticError:Aprogramcannotbeatthebottom.u`SeeNthesemanticpackagedocumentationforexplanation. u`Type rHNforimmediatehelp.zq...XWhenZyouareusingacommandasanargumentsemanticwillcopythelan Iguage4fromthenestedcommandandautomaticlyplacethetwo4guresinpropGorItion toeachother.YdInthiswaybigtranslationdiagramscaneasilybGedrawn.YdTheIhole&constructionshouldbGeplacedusingaf\putcommand,'wherether}/eferenceIp}/oint\isithecenterofthebGottomofthegurecorrespondingtotheoutermostIcommand.TI+/think+gafewexamples(withthereferencepGointmarkedby+gr +g)willIclarifyU someofthesepGoint:U񨍍32fd32fdLΟ(feLΟ(fe*S@TL'r32fdLΟfeLΟfe32LLΟ Ήfe32LLΟ Ήfe32fe*P32fdP32fd632fd"32fdLΟfeTLΟfe"LΟfe6LΟfe՚'!*CT32fdhLΟfeTLΟfe32TLήTLΟ Ήfe32hLhLΟ Ήfe^32fe[*P[*MB*M"32fd"T&T0,)*M)*M*CrIisU obtainedbythecommandsb\begin{picture}(220,75)(0,-35) fP\put(10,0){\interpreter{S,L'}}fP\put(110,0){\program{P,\compiler{C,\machine{M},\program{P,M}}}}b\end{picture}INotejfromthesecondexample,oJthatwhen\compilerisusedasimplementation Ilanguage-argument3itisbyconventionattributedtotherightofthegure. mItIiséalsoworthmentioningthatthereisnostrictdemandonwhichcommandyouIshoulduchoGoseastheoutermost,ie.thesecondexamplecouldalsobewritten(withIaU changeinthecoGordinatesto\putduetothenewreferencepoint)asb\put(160,-20){\compiler{\program{P,C},\machine{M},\program{P,M}}}(5E soIstarting'ointhemiddleinsteadofusingaleft-to-right-approachin'factitwill Ioften6bGeeasiesttostartinthemiddleasthisgivestheleastnestingmakingitIeasierU toendtheargumentsattherightpGosition.XThoughusingnestingitisinsomerarecasesadequatetousedierentlanguageIsymbGols̔onthetwosidesofthelineoftouch.CE.g.whendescribingbGootstrappringItheVpGoorU-codeimplementationcanbesymbolizedbyAU^,)KwhichstillisexecutedIonRaU-machine.iThiscanbGedonebyprovidingthesymbGol-commandwithanIoptional#argumentimmediatelyafterthecommandname.InthiswaythebGootIstrapping:Z񨍍32fdP32fd32fd׀32fdLΟfe LΟfeLΟfeLΟfe՚܀!32fdP32fd32fd32fdLΟfeLΟfeLΟfeLΟfe՚!@TML*U@TML@TML32fdP32fd32fd 32fdLΟfe;LΟfe LΟfeLΟfe՚!32fdP32fd32fd׀32fdLΟfe LΟfeLΟfeLΟfe՚܀!@TML*U@TML@TML32fdP32fdO32fd;32fdLΟfemLΟfe;LΟfeOLΟfe՚@!'@TML[*UB*U)*U 32fd T T*U, *U^,*U^׀32fd׀TۀT*U,ۀ*U^IisU typGedb\compiler{\compiler{ML,ML,U},\machine[U$^-$]{U},\compiler{ y\compiler{ML,ML,U},\machine[U$^-$]{U},\compiler{ML,U,U}}}XWhencalculatingthedimensionsofthepicture-environmentitisgoGodto IknowU thedimensionsofthegures,whichisgiveninunitsof\unitlength:$8Icompiler:q80*40Iinterpreter:q20*40machine:q20*17.1program:q20*40!֍I4`SomeG\NotesabpouttheFiles~Isemanticisdistributedinthetwolessemantic.dtxandsemantic.ins.Isemantic.dtxꐹisthemostimpGortantasitcontainsalltheessentialsusersguide,IcoGdeanddocumentationofthecodewhilesemantic.insisusedonlytoguideI@#-%5 dcss1000@doGcstripU ingeneratingsemantic.styfromsemantic.dtx.XT*o2get[[and]]usedin\comp,6\evaland\exesemantictriestoloadtheIpackqage@bbGoldwrittenby23A.|Jeffrey.ZIfthisisnotinstalledonyoursystem,theIsymbGolsyaresimulatedbydrawingtogethertosharps.ߡIywillhoweverrecommendIthatU youget@bbGoldfromyournearestCT*AN-archive.XInadditiontotheusersguideyoukqanalsogetthefullydoGcumentedcoGde.@Y*ouIwillRWhoweveronlyneedthisifyouwillsneakinhowIRVimplementedthemacrosorIchangeM somepartofthepackqage.nY*oushouldstartbyeditingsemantic.dtxandImakeU thetwolines(nearline1545)b\OnlyDescription8%NMaketoacommenttogetthedocumentation b\DisableCrossrefs+%NRemovecommentiftheindexisreadyorifIinU toacommentandremove%fromthebGeginingofthetwonextlines:b%\CodelineIndexW%NMakeaindexofthecommandusageb%\RecordChangesW%NMakethechangeshistory(6TӠsoIThenyyoushouldrunLfAzTUY&E9Xtwiceontheeditedletogetacorrecttableof Icontents.qThenU yougeneratetheindexandchangehistoryusingmakeindex:bmakeindexN-sgind.istsemantic bmakeindexN-sgglo.ist-osemantic.glssemantic.gloIAndU atlastthedoGcumentationisreadyforprintingafteranotherrunofLfAzTUY&E9X.Xsemantic.dtx;isdesignedtobGeusedwith@docand@docstrip.IItthereforeconIsistspofthepackqagecoGdebutmostofallofalotofcommentscontaningtheusersIguideandthedoGcumentationofthecode.=WhenTUY&E9Xisrunnedonsemantic.ins,I@doGcisusedtoremoveallthesecommentsandtheresultiswritteninthepackIage-lesemantic.sty.bWhenyoumaketheusersguidebyrunningLfAzTUY&E9XonIsemantic.dtx,f2LfAzTUY&E9XarstskipsabGout650linesofcomments(containingtheIsourceoftheusersguide)bGeforeitgetstothelinesnormallymakingupthepackIage-le.4 Thenfollows850linesofintermixedcommentsandcoGdedeningthecomImandsinthepackqage.mAtlastLfAzTUY&E9Xcomestoaline\documentclass{ltxdoc}I(@ltxdoGcœisLfAzTUY&E9X2"*='sstandardclassfordocumenting).AfteracoupleofpackIagesloadingOandsomecommanddenitionitreaches\begin{document}andI\docinput{semantic.dtx}.7ThismakesLfAzTUY&E9X'sreadingoversemantic.dtxonceImoreU butthistimeskippingthe%-charsintherstcolumn. ?OL_7*qqdcr2074cIA!",q cmsy10A ]tAtelastthebGorrowingformalstu:IY*ouaencouragedtocopy*,use,delete]tetc.thepackqage(semantic.dtxandsemantic.ins)asmuchasyourheartIdesiresaslongasyoupassitonincomplete(ie.notonlysemantic.sty).FY*ouIare?welcometosneakinthecoGdeandgetinspiration(A littlewarninghowever:Ithis2ismyrstbunchofrealTUY&E9X-coGde!).fY*oushouldjustremembGer:2c`K G19951996IPћkM dcsl09009?dcr05008*= manfnt7*qqdcr20745 cmsy945" cmmi92\g> dccc10001adctt08000][dcr0600,Cscmtt8+ dcbx1000$qkffffdcbx1440##|ffffdcr1440"r dcti0900!l dcbx0900  dcr0900Cdcr0800L dctt1200q% cmsy6K cmsy8;cmmi62cmmi8Aacmr6e dcr1200!", cmsy10'LGGdctt17280GGdcr1728 " dcr1000 !", cmsy10 O!cmsy7 0ncmsy5 b> cmmi10K`y cmr10ٓRcmr7< lcircle10O line10u cmex10pC