ebook img

Stanford Artificial Intelligence Laboratory Memo AIM-298 I Computer Science Department Report ... PDF

88 Pages·1998·1.99 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Stanford Artificial Intelligence Laboratory Memo AIM-298 I Computer Science Department Report ...

Stanford Artificial Intelligence Laboratory . 1977 Memo AIM-298 I Computer Science Department Report No. STAN-CS-77-6 11 T H E L O G I C O F C O M P U T E R P R O G R A M M I NG bY ZOHAR MANNA RICHARD WALDINGER Research sponsored by eciffO fo lavaNhcraeseR National Science Foundation and decnavdA hcraeseR stcejorPycnegA RETUPMOC ECNEICSTNEMTRAPED Stanford University I I Stanford Artificial Intelligence Laboratory August 1977 Memo AIM-298 Computer Science Department , Report No. STAN-CS-77-611 THE LOGIC OF COMPUTER PROGRAMMING RAHOZANNAM DRAHCIR REGNIDLAW laicifitrA ecnegilletnI baL Artificial Intelligence Center Stanford University IRS lanoitanretnI Stanford, California olneM ,kraP filaC alnro Abstract: Techniques derived from mathematical logic promise to provide an alternative to the conventional methodology for constructing, debugging, and optimizing computer programs. ,yletamitllL eseht seuqinhcet era dednetni ot dael ot eht noitamotua fo ynam fo eht stecaf foeht gnimmargorp- .ssecorp sihT repap sedivorp a deifinu lairotut noitisopxe fo eht lacigol ,seuqinhcet gnitartsulli hcae htiw .selpmaxe ehT shtgnerts dna snoitatimil fo hcae euqinhcet sa a lacitcarpgnimmargorp dia era dessessa dna stpmetta ot tnemelpmi eseht sdohtem ni latnemirepxe smetsys era .dessucsid ’ This research was supported in part by the Advanced Research Projects Agency of the Department of Defense under Contract MDA903-76-C-0206, by the National Science Fou.ndation under Grant DCRE-03737 A01, by the Office of Naval Research under Contracts NOOO14-76-C-0687 and ,6180-C-57-41OOON and by a grant from the United States-Israel Binational Science Foundation (BSF), Jerusalem, Israel. The views and conclusions contained in this document are those of the authors and should not be interpreted as necessarily representing the official policies, either expressed or implied, of Stanford University, Stanford Research Institute, or the VS. Government. Copyright 0 1977 by Zohar Manna and Richard Waldlnger. Nlanna & Waldinger ehT cigoL fo retupmoC gnimmargorP Contents: I. Introduction ................................................................ 2 .II Partial Correctness ........................................................ 6 .III Termination ..,..,......,.....,.......................,..........,........., 27 . .VI dednuoF-lleW noitcudnI ,,..,,..,.,...............................,..,*..*. 32 *v Total Correctness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 .IV . . .. .s . m. .a . r. .g . o. .r e. P.v . i. .s . r. . u. .c . e.f s.R o.s . e. .n . t. .c . e..r.roC 04 I .IIV Program Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..... 50 .IIIV mar.gorP Development .................................................... 61 ,XI References ................................................................ ‘76 I Manna & Waldinger ehT cigoL fo retupmoC gnimmargorP I. Introduction nI enuJ ,2691 eht tsrif naciremA ecaps eborp ot suneV reniraM( )I tnew ffo esruoc dna dahot eb deyortsed esuaceb fo na rorre ni eno fo eht ecnadiug smargorp ni sti onboard computer. enO tnemetats fo eht ,margorp hguoht yllacitcatnys ,tcerroc dah a gninaem rehtegotlatnereffid from that intended by the programmer. hguohtlA wef sgub evah hcus ralucatceps,stceffe srorre ni retupmoc smargorp era tneuqerf dna .laitneulfni erehT sah neeb laitnatsbus troffe yltnecer ot ylppa lacitamehtam rogir ot eht gnimmargorp ssecorp dna ot elbane eht ycaruccafo eht enihcam ot etasnepmoc rof eht enorp-rorre namuh.dnim In the late nineteenth and early twentieth century, mathematics underwent a process of noitazilamrof dna ,noitazitamoixa yllaitrap ni na troffe ot epacse morf sexodarap dna lacigol srorre deretnuocne yb suoiverp snoitareneg fo .snaicitamehtam A ralimis ssecorp siyawrednu in the development of a logical theory of programs.’ This theory has already made our gnidnatsrednu fo smargorp erom esicerp dna yam noos etatilicaf ruo noitcurtsnoc foretupmoc smargorp sa.llew lacigoL seuqinhcet era gnieb depoleved ot evorp smargorp ,tcerroc ottceted programming errors, to improve the efficiency of program operation, to extend or modify gnitsixe ,smargorp dna neve ot tcurtsnoc wen smargorp gniyfsitas a nevig ;noitacificeps ynamfo these techniques have been implemented in experimental programming systems. In the last ,edaced siht dleif fo hcraeser sah neeb ylemertxe ;evitca ti won sah eht laitnetop ot trexe apeed ecneulfni no eht yaw retupmoc smargorp era.decudorp ehT elbaliava seuqinhcet era ydaerla debircsed ni eht ,erutaretil tub eht tnaveler srepap era derettacs hguorht ynam lacinhcet slanruoj dna ,stroper era nettirw ni a yteirav foelbitapmocni ,snoitaton dna era netfo elbadaernu tuohtiw emos dnuorgkcab ni lacitamehtam .cigol nIsiht ,repap ew tpmetta ot tneserp eht lapicnirp sdohtem nihtiw a deifinu ,krowemarf gniyevnoceht noitiutni dniheb eht sdohtem yb ,selpmaxe dna gnidiova eht lamrof sutarappa fo eht.snaicigol To facilitate a comparison between the various techniques, we use a number of different smhtirogla rof gnimrofrep eht emas :ksat ot etupmoc eht tsetaerg nommoc rosivid fo owt .sregetni esehT smhtirogla era elpmis hguone ot eb ylidaer ,dootsrednu tub eltbus hguoneot etartsnomed lacipyt.seitluciffid \ ehT tsetaerg nommoc rosivid fo owt evitagennon sregetni x dna y , detaiverbba sa g&(x ,)ysi eht tsegral regetni taht sedivid htob x dna 1 . For instance: 9(dcg 12) = 3, g&(12 25) = ,1dna 0(dcg 14) = .41 nehW x dna y era htob orez ereht si on tsetaerg nommoc ,rosividesuaceb yreve regetni sedivid ;orez no eht rehto ,dnah nehw x ro y si ton ,orez a greatest common rosivid tsum.tsixe A evian mhtirogla ot etupmoc eht dcg fo x dna 7 thgim evaheb sa :swollof ekaM stsil folla the divisors of’x dna& fo lla eht srosivid fo r ; neht ekam a driht tsil fo lla eht srebmuntaht 2 Manna & Waldinger ehT cigoL fo retupmoC gnimmargorP raeppa ni htob stsil eseht( era eht nommoc srosivid fo x and J ;) finally, find the largest rebmun ni eht driht tsil siht( si eht tsetaerg nommoc rosivid fo x dna 7 ). ehT cases nihcihw x ro 7 si orez tsum eb deldnah.yletarapes sihT mhtirogla si drawrofthgiarts tub tneiciffeni esuaceb ti seriuqer na !visnepxe ,noitarepo gnitupmoc lla eht srosivid fo a nevig ,rebmundna esuaceb ti tsum rebmemer eerht stsil fo etaidemretni srebmun ot etupmoc a elgnis.rebmun A erom eltbus tub erom tneiciffe mhtirogla ot etupmoc eht dcg fo owt srebmun nac eb.desived litnJI eht tsrif rebmun si ,orez taeper eht gniwollof:ssecorp fi eht dnoces rebmun si retaerg than or equal to the first, ecalper ti yb rieht ecnereffid-- otherwise interchange the two numbers -- and continue. When the first number becomes zero, the answer is the second .rebmun sihT rewsna snrut tuo ot eb eht gcd fo eht owt lanigiro .srebmun ehT wenmhtirogla si erom tneiciffe naht eht evian ,eno esuaceb ti ylno sdeen ot rebmemer owt srebmun ta ynaeno emit dna ot mrofrep eht elpmis runim operation. ehT evoba mhtirogla nac eb desserpxe sa a dezilyts:margorp margorP A eht( evitcartbus :)mhtirogla input(q) )07 x( )7 + 0x( )07 more: fi x = 0 neht otog enough fi y 1 x then 7 t x-y esle x( )7 t (r )x got0 more enough: .)ituptuo The notation x( )y t ox( )oy snaem taht eht seulav fo x dna IJ era ylsuoenatlumis tes ot eht input values 0x dna .y ,suhT eht tnemetats x( )u e (r X) has the effect of interchanging the values of x dna J . sihT margorp sesuac eht gniwollof ecneuqes fo seulav fo x dna IJ oteb detareneg ni gnitupmoc eht gcd fo eht tupni seulav 6=0x dna :3-0~ x = 6 dna y = 3, x = 3 and y = 6, x = 3 dna y = 3, x = 3 dna r = 0, x = 0 and IJ = 3. ,suhT eht tuptuo fo eht margorp si.3 hguohtlA eht reilrae evian mhtirogla saw ylsuoivbo ,tcerroc esuaceb ti ylesolc dewollof eht noitinifed fo gcd, ti si yb on snaem tnedive taht margorP A setupmoc eht gcd function. First fo ,lla ti si ton raelc taht nehw x semoceb ,orez eht eulav fo y lliw eb eht 4tg fo eht;stupni taht siht si os sdneped no seitreporp fo eht gcd .noitcnuf ,eromrehtruF ti si ton suoivbo taht x 3 Manna & Waldinger ehT cigoL fo retupmoC gnimmargorP I lliw reve emoceb ;orez ew thgim yfdetaeper etucexe eht If-then-else statement forever. For ,ecnatsni redisnoc eht margorp A ’ deniatbo morf A yb gnicalper ehtlanoitidnoc fi y 1 x then y c y-x else x( y) e y( x) yb fi y i’x nehi y t x-9 else x t x-y. sihT margorp ylesolc selbmeser margorP ,A dna ti yllautca seod etupmoc eht gcd fo stistupni nehw ti sneppah ot ecudorp na .tuptuo ,revewoH ti lliw nur reverof dna reven ecudorpna tuptuo rof ynam elbissop tupni ;seulav rof ,ecnatsni fi x0*0 dna ,O=oy ro fi *0x 0 dna .~x=~IJ ,suhT fi =oy=ox ,e 3 cg enn sveieei uwhusfqotlsoel aeslfvcoocfus x dna g : segreme x = 3 dna y = 3, x = 3 dna y = 0, x = 3 and y = 0, x - 3 dna y = 0,. . . . esehT smargorp era sa elpmis sa yna ew era ylekil ot ,retnuocne dna tey rieht ssentcerroc siton yletaidemmi .raelc tI si ton ,gnisirprus ,erofereht taht sgub rucco ni egral erawtfos.smetsys hguohtlA smargorp yam eb detcejbus ot evisnetxe ,gnitset eltbus sgub yltneuqerf evivruseht gnitset.ssecorp nA evitanretla hcaorppa si ot evorp yllacitamehtam taht sgub tonnacylbissop rucco- ni eht .margorp hguohtlA erom tluciffid ot ylppa naht ,gnitset hcus lacitamehtamsfoorp tpmetta ot trapmi etulosba ytniatrec taht eht margorp ,si ,deedni.tcerroc Techniques derived from mathematical logic have been applied to many aspects of the gnimmargorp ,ssecorp -:gnidulcni ’ 0 :ssentcerroc gnivorp taht a nevig margorp secudorp eht dednetni.stluser l termination: gn itvaohrtp y a lm.nlap earolvugtlitosignrwepve l transformation: gnignahc a nevig margorp otni na tnelaviuqe ,eno netfo ot evorpmisti ycneiciffe (optimization). @ development: gnitcurts naoc margorp ot teem a.no inteavciigficeps esehT seuqinhcet era dednetni ot eb deilppa yb eht ,remmargorp yllausu htiw emos eergedfo computer .ecnatissa emoS fo eht seuqinhcet era ylriaf llew dootsrednu dna era ydaerlagnieb incorporated into experimental programming systems. Others are just beginning to be detalumrof dna era ylekilnu ot eb fo lacitcarp eulav rof emos.emit 1 4 Manna & Waldinger ehT cigoL fo retupmoC gnimmargorP ruO noitisopxe si dedivid neewteb a cisab ,txet nevig ni na yranidro epyt tnof and secondary notes interspersed throughout the text in a smaller font. The basic text presents the principal logical techniques as they would be applied by hand; the secondary notes discuss subsidiary topics, report on implementation efforts, and include bibliographical remarks. Only, a few references are given for each topic, even though we are likely to lose some good friends in this way. ehT ytsah redaer yam piks lla eht yradnocesseton without loss of continuity. In the following ,s e ehglwcal upinohwotcae fo ;scipot we nigeb htiw ,ssentcerroc the detagitsevni and best understood of them .lla

Description:
THE LOGIC OF COMPUTER PROGRAMMING Department of Defense under Contract MDA903-76-C-0206, by the National Science Government.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.