You are on page 1of 7
Artificial Intelligence Project---RLE and ‘Computation Center mo Memo 12 — RECURSIVE FUNCTIONS OF SYMBOLIC EXPRESSIONS ‘AND. THEIR COMPUTATION BY MACHINE : by 3. NeCerthy "This memorandum 19 a sontamuatten. of Mepe 8° 5. Recursive Functions and Com 5.2 Recursive Functions of Nuserical arguments Conditional expressions and recursive function definitions as devices to assist in describing procedures are applicable to other kinds of programming than symbolic manipulations. For example, the Newton algorithm for computing the square root of a mumber a starting with an initial approximation x may be described by 2 ‘iqrt (a 5x) o{ LE =8L c¢xy1-sart [asd fer? J] Another example ts the Euclidean algorithm for the greatest common ¢ivision of tuo integers m and n. ged finsn]= [mc n—sged [nim] ;rem [n/n] =0~rn;1—>g0d [nsren[m/n] ] where by rem[m/n] we meen the remainder left on dividing m by n. This function in turn may be defined by vex [m/n]~ [a0;n/ =m—n3 3 din{m zn] We further define m4ne [neO—>mj1m’ +4im[n]] and mén= [n=0—90, 1» memedim[n] ] 5.2 Flow Charts and Recursion Since both the usual form of computer program and recursive funetion definitions are universal somputationally it is interest- ing to display the relation between them. The translation of recursive symbolic functions into computer programs will be the subject of most of the remainder of this paper. In this section we show how to go the other way, at least in principle. ‘The state of the machine at ary time during a computation 1s given by the values of a number of variables. Let these variables be combined into a vector =. Consider a block of program with one entrance and one exit. It defines and is essentially defined by a certain function f which takes one /~ mechine configuration into another, i.e. f has the form Ber(s). \- det us call f the associated function of the program block. Now let a number of such blocks be combined into a program by decision elements 7 which after each block is completed decide which block will be entered next, However, let the whole pro- gram still have one entrance and one exit. We shall give as an “\ example a flow chart. Lat us describe the function r{k] which gives the trans- formation of the vector between entrance and exit of the whole block, we shall define it in conjunc- tion with functions s[{é] and t[%] which give the transformations ] undergoes between the points S and T respectively and the exit. We have 05} Passports +e 021) ce a etsy orto do-oley08I1] - Given a flow chart with a single entrance and a single exit 1t is easy to write down the recursive function which gives the 1 i a L transformation of the stave vector from entrance to exit in terus of the ccvresponding functicns for the computation blocks and the predicates of the branch points. In general, we proceed as follows: In the diagram let p be an n-way branch point, let f,,...f, be the fcllowing computations heading to branch points 8,, 8, ...P,. Let ve the function transforming 5 between P and the exit of the chart and let 1, +++s¢, be the cor- responding functions for By, .--, B,+ We then write els) «[pyfe} oats] ]h-.-27, &] ~? © alfals]]] ‘There are, however, problens connected with the descriptions of the functions f describing the computation blocks. ‘These are 1. Bach block usually affects only a few of the components of the vector & and 1s best described in terus which involve only the couponents affected and those on which they depend. Such a description 1s not affected by adding other compcnents to the totel vector = for other parts of the program. ‘the so-called arithmetic or replacement statement of Fortran, It or IAL which has the form An€ {B.C 4s of this kind. Sven input and output statements can be included 4n this scheme provided the states of external media are included in the vector 5. 2. A subbleck in a flow chart may also be recursively defined. Usually the vector for the subblock will be conveniently described as having a different set of components from the program as a whole. There wili be both variables (i.e. components) internal to the subblock and variables not involved in the subcaleulation. To adequately describe this, requires a notation for extensions and reductions of vector functions. 3. Sven with a notation for extensions and reductions, sub- routines require additional treatment. A subroutine ocourring at Py <4 several places in the program will’ ee components at each place. In vat different places it seens to have | permutation of variables. CS-TR Scanning Project Document Control Form Date :_//)_30)_ Report #_ AIM —1 Each of the following should be identified by a checkmark: Originating Department: Artificial Intellegence Laboratory (Al) (1) Laboratory for Computer Science (LCS) Document Type: C Technical Report (TR) {Technical Memo (TM) O Other: Document Information Number of pages: 5 { ‘1-1 masés ) akon OD me, pre sco aol ges Originals are: Intended to be printed as : C Single-sided or CO Single-sided or O Double-sided O Double-sided Print type: Tyoewter — )oftet Press]. Laser Print CO tree ner ) Unirown fot: mimeo erred (Foe) Check each if included with document: O 000 Form Funding Agent Form Oi Cover Page O Spine CO Printers Notes CO Photo negatives O Other: Page Data: Blank PageSer ea nna Photographs/Tonal Material oy poe nmm Other (rom secresorvpage nent Description Page Number: cemaAcE ma! (1-5) Uniti en Tree PAGE| 621) Seance TRET’s (3 Scanning Agent Signoff: Date Received: _[// 30/95. Date Scanned: [2/14/15 Date Returned: _/3/ pS scanning soon sonae,___Puueland W. Got. erctmmmmcenttmeteet Scanning Agent Identification Target Scanning of this document was supported in part by the Corporation for National Research Initiatives, using funds from the Advanced Research Projects Agency of the United states Government under Grant: MDA972-92-J1029. The scanning agent for this project was the Document Services department of the M.I.T Libraries. Technical support for this project was also provided by the M.LT. Laboratory for Computer Sciences. arptepn pw Rev. 994

You might also like