A TURING MACHINE FOR EXPONENTIAL FUNCTION g(x,y) = xy Pedro Lemos Centre for Logic, Epistemology and the History of Science (CLE-Unicamp) Contact: pedromendeslemos@gmail.com This is a Turing Machine which computes the exponential function g(x,y) = xy, where x, y  1. Instructions format and operation of this machine are intended to best reflect the basic intuitions and conditions outlined by Alan Turing in his On Computable Numbers, with an Application to the Entscheidungsproblem (1936), using a version in essence due to Kleene (1952) and Carnielli & Epstein (2008). Hence, a complete instruction will consist of a quadruple (qi, S, Op, qj), where qi is the current state, S  {0, 1} is the current symbol (read by the head), Op  {1, 0, R, L} is an operation, and qj is the new state. This machine is composed by 4 basic task machines: one which checks if exponent y is zero, a second which checks if base x is zero, a third that is able to copy the base, and a fourth able to multiply multiple factors (in this case, factors will be all equal). They were conveniently separated in order to ease the UHDGHU*s task to understand each step of its operation. We adopt the convention that a number n is represented by a string of n+1 symbols  1μThus, an entry (x, y) will be represented by two respective strings of x+1 and y+1 V\PEROV  1μ separated by a single  0μ (or a blank), and as an output, this machine will generate a string of xy+1 symbols  1μ 6RPHLQVWUXFWLRQVDUHIROORZHGE\DEULHIGHVFULSWLRQRIZKDW*VJRing on. This machine can be tested on the internet. We adapted the instructions to a particular format, so it could be implemented on a java based TM emulator. These are presented right after our TM instructions. (I) MACHINE (A) ± The Zero Exponent Checker q1 1 R q1 2 Head passes through the base q1 0 R q2 q2 1 R q3 2 Checks if exponent is zero q3 0 1 q4 2 Exponent is zero, it erases the exponent and writes 1, resulting string  μ q4 1 L q4 q4 0 L q5 q5 1 O q5 2 Starts to erase the base q5 0 L q6 q6 1 1 q5 q6 0 0 q7 q7 0 R q7 q7 1 1 q66 2 Halts the machine in standard position, that is, in the leftmost symbol  μRIWKHVWULQJ q3 1 1 q8 2 Exponent is not zero, goes back to base and implements Machine (B) q8 1 L q8 q8 0 L q9 (II) MACHINE (B) 2 The Zero Base Checker q9 1 L q10 q10 0 R q11 2 Base is zero, erases the exponent and halts in standard position q11 1 R q11 q11 0 R q12 q12 1 0 q12 q12 0 R q13 q13 1 1 q12 q13 0 0 q14 q14 0 L q14 q14 1 1 q66 q10 1 1 q15 2 Base is not zero, JRHVWRWKHULJKWPRVW μRIH[SRQHQWDQGLPSOHPHQWV Machine (C) q15 1 R q15 q15 0 R q16 q16 1 R q16 q16 0 L q17 (III) MACHINE (C) The Base copier q17 1 L q18 2 First this machine checks if exponent is, or has reached, number 1. If it has just started, and it finds out 1, it enters state q19, and erases exponent. If it verifies it KDVQRWUHDFKHGVWULQJ 110..μthis stage will work until exponent is reduced to number 1. q18 1 L q19 q19 0 R q37 2 Exponent is, or has reached, number 1. It now erases exponent. q37 1 0 q37 q37 0 R q38 q38 1 0 q39 q39 0 L q39 q39 1 1 q40 2 Exponent is now erased and the head is positioned on the rightmost  μ RI WKH rightmost factor (This is the moment when we have y copies of the base, and we can implement Machine (D), the multiplier of multiple factors). q19 1 R q20 2 ([SRQHQWLVQRWRUKDVQ*WUHDFKHGQXPEHU; Goes back to the rightmost  μDQGVWDUWVRUFRQWLQXHVWRFRS\WKHEase q20 1 R q21 q21 1 0 q21 2 7KLVLVWKHPRPHQWZKHQZHHUDVHDV\PERO μ of the exponent, move the head to the leftmost copy of the base, and duplicate it. If we have just started, our own base will be the  OHIWPRVWFRS\μ, otherwise, the head will move until it reaches the leftmost copy of the base, and replicate it. q21 0 L q22 q22 1 L q22 q22 0 L q23 q23 1 1 q22 2 Every time it finds a string, the head passes through it q23 0 1 q24 2 We found the leftmost copy, the head writes a symbol  μ, so it knows where the new copy should be written. q24 1 R q24 q24 0 R q25 q25 1 R q26 2 Notice that when returning to the string which is being copied, it first tests if LWZDVDOUHDG\UHGXFHGWRDVLQJOHV\PERO μ. If this is the case, then it starts to rewrite the symbols which were erased from the original string q26 1 1 q27 2 Implements, or continues, the process of erasing symbols q27 1 R q27 q27 0 L q28 q28 1 0 q28 q28 0 L q29 q29 1 L q29 q29 0 L q30 q30 1 L q30 q30 0 0 q23 q26 0 1 q31 2 ,WIRXQGDVLQJOH μ, starts rewriting the symbols, and then goes back to the exponent q31 1 R q32 q32 0 0 q26 q32 1 L q33 q33 1 0 q33 q33 0 R q 34 q34 1 R q34 q34 0 R q35 q35 1 1 q34 q35 0 L q36 q36 0 L q17Back to exponent, enters state q17 to verify if it was reduced to number 1 (IV) MACHINE (D) 2 The Multiplier of Multiple Factors q40 1 L q40 2 Checks if there is a string to multiply. q40 0 L q41 q41 0 0 q65 q65 0 R q65 q65 1 1 q66 2 Machine halts q41 1 1 q42 2 There is a string to multiply, the head will now find the leftmost factor, and writes a symbol  μ MXVWOHIWWRWKDWIDFWRUVHSDUDWHGE\DVLQJOH μZKHUHwe leave the product q42 1 L q42 q42 0 L q43 q43 1 1 q42 q43 0 1 q44 q44 1 R q44 q44 0 R q45 q45 1 1 q44 q45 0 L q46 q46 0 L q46 q46 1 L q47 2 Now it will test if the multiplier has reached number zero. Notice that, differently from Machine (C), which checks if H[SRQHQW KDV EHHQ UHGXFHG WR  ««μ this machine checks for a zero, this happens because each symbol of the multiplier makes a copy of the factor, and leaves the whole product in the leftmost string, thus erasing both the multiplier and the factor that is being multiplied. q47 0 R q61 2 Multiplier string has reached number zero q61 1 0 q62 q62 0 L q62 q62 1 0 q63 2 Starts to erase the factor that has been multiplied q63 0 L q64 q64 1 1 q62 q64 0 L q40 2 Back to state q40, to check if there is a string to multiply, or if we have reached the desired result q47 1 R q48 0XOWLSOLHUVWULQJKDVQRWUHDFKHG μ, so it starts (or continues) to multiply the factor in its left q48 1 0 q48 2 Erases a symbol from the Multiplier q48 0 L q49 q49 1 L q49 q49 0 L q50 q50 1 0 q50 2 (UDVHV μIURPWKHIDFWRUDQGZULWHVDV\PERO μ in the product string q50 0 L q51 q51 1 L q51 q51 0 L q52 q52 1 1 q51 q52 0 R q67 2 Found where the product string is q67 0 1 q53 q53 1 R q53 2 Now the head moves right, until it reaches the factor that is being multiplied. q53 0 R q54 q54 1 1 q53 q54 0 L q55 q55 0 L q55 q55 1 L q56 2 7HVWVLIPXOWLSOLHGIDFWRUKDVEHHQUHGXFHGWR μ q56 1 R q50 2 Back to state q50 q56 0 R q57 Factor has been UHGXFHGWR μ, starts rewriting the symbols it has erased. q57 1 R q58 q58 0 1 q57 q58 1 L q59 q59 1 0 q59 q59 0 R q60 q60 1 R q60 q60 0 L q46 Back to state q46, and test LI0XOWLSOLHUKDVEHHQUHGXFHGWR ««μ (V) Instructions to implement this TM on the internet. The quadruples of this machine were adapted to test it, using an emulator. You first need to access the following link: http://ironphoenix.org/tril/tm/ . Then in  /Rad QHZ SURJUDPμ VHOHFW  6XEWUDFWHUμ DQG FOLFN RQ  /RDG QHZ 3URJUDPμ WKHQ FOLFN RQ  &OHDU3URJUDPμand erase the input in the box  ,QLWLDOFKDUDFWHUVRQWDSHμNow put your entry in  ,QLWLDOFKDUDFWHUVRQWDSHμlike this: type [V\PEROV μIROORZHGE\  Bμ DQG \ V\PEROV  μ WR UHSUHVHQW xy; for example, for 23, we type  Bμ (without quotation marks). Then set  ,QLWLDOWDSHSRVLWLRQμ in maximum position, that is,   μ 1RZ \RX RQO\ KDYH WR FRS\ instructions below, paste it into  3URJUDPPLQJμ box, click on  ,QVWDOO3URJUDPμand  6WDUWμ the machine. 1 1 1 > 1 _ 2 > 2 1 3 > 3 _ 4 1 4 1 4 < 4 _ 5 < 5 1 5 _ 5 _ 6 < 6 1 5 1 6 _ 7 _ 7 _ 7 > 7 1 66 1 3 1 8 1 8 1 8 < 8 _ 9 < 9 1 10 < 10 _ 11 > 11 1 11 > 11 _ 12 > 12 1 12 _ 12 _ 13 > 13 1 12 1 13 _ 14 _ 14 _ 14 < 14 1 66 1 10 1 15 1 15 1 15 > 15 _ 16 > 16 1 16 > 16 _ 17 < 17 1 18 < 18 1 19 < 19 _ 37 > 37 1 37 _ 37 _ 38 > 38 1 39 _ 39 _ 39 < 39 1 40 1 19 1 20 > 20 1 21 > 21 1 21 _ 21 _ 22 < 22 1 22 < 22 _ 23 < 23 1 22 1 23 _ 24 1 24 1 24 > 24 _ 25 > 25 1 26 > 26 1 27 1 27 1 27 > 27 _ 28 < 28 1 28 _ 28 _ 29 < 29 1 29 < 29 _ 30 < 30 1 30 < 30 _ 23 _ 26 _ 31 1 31 1 32 > 32 _ 26 _ 32 1 33 < 33 1 33 _ 33 _ 34 > 34 1 34 > 34 _ 35 > 35 1 34 1 35 _ 36 < 36 _ 17 < 40 1 40 < 40 _ 41 < 41 _ 65 _ 65 _ 65 > 65 1 66 1 41 1 42 1 42 1 42 < 42 _ 43 < 43 1 42 1 43 _ 44 1 44 1 44 > 44 _ 45 > 45 1 44 1 45 _ 46 < 46 _ 46 < 46 1 47 < 47 _ 61 > 61 1 62 _ 62 _ 62 < 62 1 63 _ 63 _ 64 < 64 1 62 1 64 _ 40 < 47 1 48 > 48 1 48 _ 48 _ 49 < 49 1 49 < 49 _ 50 < 50 1 50 _ 50 _ 51 < 51 1 51 < 51 _ 52 < 52 1 51 1 52 _ 67 > 67 _ 53 1 53 1 53 > 53 _ 54 > 54 1 53 1 54 _ 55 < 55 _ 55 < 55 1 56 < 56 1 50 > 56 _ 57 > 57 1 58 > 58 _ 57 1 58 1 59 < 59 1 59 _ 59 _ 60 > 60 1 60 > 60 _ 46 <