💾 Archived View for gemini.quux.org › h › Software › Emulators › Turing › Java › tmjava.html captured on 2024-08-18 at 23:57:42.

View Raw

More Information

-=-=-=-=-=-=-

<HTML><HEAD>
<TITLE>Alan Turing Internet Scrapbook: A Java Turing Machine</TITLE>
<META name="keywords" content="Alan Turing, Turing machine, Java applet, computable numbers, theory of computation">
         <META name="description" content="Java simulation of a Turing machine, as formulated by Alan Turing in 1936 in his paper 'On Computable Numbers'.">

</HEAD>
<body background="../icons/whitestone.gif"  link="#800000" vlink="#101000">
<h1>The Alan Turing Internet Scrapbook</h1>

<table width=100%>
<tr><td align=left><h2>Turing Machine simulation in Java</h2>
</td>
<td align=right><a href="./index.html"><img border=0 height=98 width=70 src="../icons/scrap.gif"></a></td></tr></table>

<hr><br>
<p>
<table width=100% height=40><tr bgcolor="#c0c0c0"><td width=15% align=center>maintained by<br> <a href="http://www.synth.co.uk">Andrew Hodges</a></td><td width=15% align=center><a href="../index.html">Alan Turing<br>home page</a></td><td width=15% align=center><a href="./index.html">Scrapbook index</a></td><td width=15% align=center><a href="../bio/index.html">Short Biography</a></td><td width=15% align=center><a href="http://www.turing.org.uk/sources/biblio.html">Bibliography</a></td><td width=15% align=center><a href="http://www.turing.org.uk/book/">My Books</a></td></tr></table><p><hr><br><p>

<table width=100% cellpadding=6 bgcolor="#FFFFFF"><td>
<h1>A Turing Machine Applet</h1> 

<center>
<table border=5 cellpadding = 10 width=80% bgcolor="#c0c0c0"><tr><td align=center >The Applet on this page has been written by Graham Stalker-Wilde<br> <a href="mailto:grahams@pipeline.com">grahams@pipeline.com</a><p>
 
He has generously allowed it to be used on this site, and you may download for personal use the Java source in <a href="../java/TM-GSW-source.txt">this file.</a> <p> The Applet code is ©Graham Stalker-Wilde.</td></tr></table></center>
<p>
This Applet is powerful enough to run any Turing machine with reasonable storage requirements, but at the moment it is only being used on this page to present a very particular, rather trivial Turing machine which performs unary addition. It has the effect of composing two groups of 1's placed on its tape into a single group of 1's, much the same as the machine described on pages 98-99 of my book <a href="http://www.turing.org.uk/book/">Alan Turing: the Enigma.</a><p>
But this is enough to illustrate the basic features of the Turing's concept -- the atomic elements, out of which any possible computation, however complicated, can be composed. Running the machine in the Applet will illustrate these general features of Turing machines:-
 <ul>
<li>a finite number of possible states ("configurations" in Turing's original 1936 paper)
<li>the scanning of one square at a time
<li>moving one place to left or right for the next symbol to be scanned
<li>how this motion and the new state is determined by the single scanned symbol.
</ul>
<p><font color="#000040"><b>
Note:</b> In this simulation, the tape moves to left or right through a fixed scanning head, rather than the head moving to right or left along the tape.
</td></table><p><hr><br><p>

<table width=100% cellpadding=6 bgcolor="#c080a0"><td>
<table width =100% cellpadding=6 bgcolor="#FFFFFF"><td>

<h2>Operating the Applet</h2>
The tape contains squares either blank ( - ) or marked with a 1.<br> The <b>scanned symbol</b> is indicated by the symbol in square brackets.<p> The table of states specifies the behaviour of the machine for each state, and for each possible scanned symbol.<p>
The <b>current state</b> is indicated by the ** asterisks.<p>
Click on STEP to see the machine operate one step.<br> Click on RUN to see it pass through the whole sequence.<br> Click on RESET to restore the original configuration.
<font color="#0040FF"><h3>Sorry folks, the applet runs on Netscape but on Internet Explorer may not display the right hand part of the tape. I hope to fix this bug later.</h3></font>
</td></table>
</td></table>
<br>
<center>
<p>
<table cellpadding=8 border=4 width=100% bgcolor="#c0c0c0"><tr><td>

<APPLET codebase= ../java code= TuringMachineApplet alt="This Applet needs Netscape 3 or an equivalent Java-enabled browser" WIDTH=450 HEIGHT=250>
<PARAM name=Alphabet value="-1">
<PARAM name=Tape value="1,1,1,0,1,1,1,1,1">
<PARAM name=TapeL value= "0">
<PARAM name=StartPosition value=0>
<PARAM name=State0 value="1,R,1,1,R,0">
<PARAM name=State1 value="0,L,2,1,R,1">
<PARAM name=State2 value="0,L,2,0,L,3">
<PARAM name=State3 value="0,R,-1,1,L,3">
</APPLET>
</td>

</tr></table></center>
<br><p>
<table width=100% cellpadding=6 bgcolor="#c080a0"><td>
<table width =100% cellpadding=6 bgcolor="#FFFFFF"><td>

<h2>
More detailed comment on the machine:</h2>
<ul>
<li> It will only work on two groups of 1's separated by a single blank. The machine is demonstrated here for the addition of 3 and 5, but the states as specified would work for input groups of any length. (The second group could be empty.)
<li>It has to start with the scanned square within the left-hand group of 1's.
<li>State 0 scans rightwards through the left-hand group, then finds and fills the blank square.
<li>State 1 scans rightwards through the right-hand group until it finds the end.
<li>State 2 erases the last 1.
<li>State 3 serves to return the scanned square to the left-hand end of the group. 
</ul>
</td></table>
</td></table>
<br><p><hr><br><p>
<table width=100% cellpadding=6 bgcolor="#FFFFFF"><td>
<h2>
A more interesting example</h2>
The same Applet as you have already downloaded is used on <b><a href="./tmjavadiv1.html">another page</a></b><br>
to show a Turing machine testing the <b>divisibility of one integer by another.</b><p><hr><br><p>
<h2>More Java</h2>
If you are interested in Java, try this 
<a href="http://www.cryptographic.co.uk/factorise.html">Applet for factorisation</a> which can test numbers up to 9223372036854775807.</a>
</td></table>
<p><hr><br><p>
<table width=100%><tr bgcolor="#FFFFFF">
<td align=center><a href="http://www.synth.co.uk/main.html"><img height=50 width=50 border=0 src="../icons/main.gif"><br>My Main Page</a></td>
<td align=center>
<a href="./machine.html"><img border=0 width=70 height=98 src="../icons/scrap.gif"><br>Continue<br>Scrapbook</a></td>
<td align=center><a  href="../index.html"><img border=0 height=87 width=63 src ="../icons/amticon.gif"><br>Alan Turing<br>Home Page</a></td>
<td align=center>
<a  href="http://www.turing.org.uk/sources/biblio.html"><img border=0 height=35 width=65 src="../icons/biblio.gif"><br>Bibliography</a>   
</td><td align=center>
<a  href="http://www.turing.org.uk/book/"><img border=0 width=80 height=115 src="../icons/book.jpeg"><br>My Book</a>   
</td></tr></table><p><hr><br><p>

Last updated 27 April 2000. <p>
I am always grateful for feedack and suggestions for new links: <a href="mailto:andrew@synth.co.uk">andrew@synth.co.uk</a>


</BODY>
</HTML>