<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://machinelearning.subwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=User%3AIssaRice%2FComputability_and_logic%2FSipser%27s_quine_in_Python</id>
	<title>User:IssaRice/Computability and logic/Sipser&#039;s quine in Python - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://machinelearning.subwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=User%3AIssaRice%2FComputability_and_logic%2FSipser%27s_quine_in_Python"/>
	<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=User:IssaRice/Computability_and_logic/Sipser%27s_quine_in_Python&amp;action=history"/>
	<updated>2026-04-26T18:43:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.2</generator>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=User:IssaRice/Computability_and_logic/Sipser%27s_quine_in_Python&amp;diff=2094&amp;oldid=prev</id>
		<title>IssaRice at 00:59, 25 June 2019</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=User:IssaRice/Computability_and_logic/Sipser%27s_quine_in_Python&amp;diff=2094&amp;oldid=prev"/>
		<updated>2019-06-25T00:59:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:59, 25 June 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l30&quot;&gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Python distinguishes between printing and returning, whereas Sipser&amp;#039;s model of Turing machines just has an output tape. Thus, in Sipser&amp;#039;s quine, part A can just run and leave things on the tape for part B to use, whereas this sort of thing isn&amp;#039;t automatic in Python (if we used separate methods for &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;, then we would have to pass the output of &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;, by e.g. calling &amp;lt;code&amp;gt;B(A())&amp;lt;/code&amp;gt;). To emulate this behavior, we use a global variable &amp;lt;code&amp;gt;TAPE&amp;lt;/code&amp;gt; where each part reads from and writes to.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Python distinguishes between printing and returning, whereas Sipser&amp;#039;s model of Turing machines just has an output tape. Thus, in Sipser&amp;#039;s quine, part A can just run and leave things on the tape for part B to use, whereas this sort of thing isn&amp;#039;t automatic in Python (if we used separate methods for &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;, then we would have to pass the output of &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;, by e.g. calling &amp;lt;code&amp;gt;B(A())&amp;lt;/code&amp;gt;). To emulate this behavior, we use a global variable &amp;lt;code&amp;gt;TAPE&amp;lt;/code&amp;gt; where each part reads from and writes to.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Python has local and global variables, so in the method &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; we must explicitly declare &amp;lt;code&amp;gt;global TAPE&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Python has local and global variables, so in the method &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; we must explicitly declare &amp;lt;code&amp;gt;global TAPE&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The above is not exactly a quine because the definition of &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; was not printed. This isn&#039;t too hard to fix but is somewhat annoying.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
	<entry>
		<id>https://machinelearning.subwiki.org/w/index.php?title=User:IssaRice/Computability_and_logic/Sipser%27s_quine_in_Python&amp;diff=2082&amp;oldid=prev</id>
		<title>IssaRice: Created page with &quot;Michael Sipser&#039;s &#039;&#039;Introduction to the Theory of Computation&#039;&#039; describes a quine using Turing machines.  Here is an implementation of the machine &#039;&#039;SELF&#039;&#039;.  &lt;pre&gt;TAPE = &quot;&quot;  de...&quot;</title>
		<link rel="alternate" type="text/html" href="https://machinelearning.subwiki.org/w/index.php?title=User:IssaRice/Computability_and_logic/Sipser%27s_quine_in_Python&amp;diff=2082&amp;oldid=prev"/>
		<updated>2019-06-19T00:09:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Michael Sipser&amp;#039;s &amp;#039;&amp;#039;Introduction to the Theory of Computation&amp;#039;&amp;#039; describes a quine using Turing machines.  Here is an implementation of the machine &amp;#039;&amp;#039;SELF&amp;#039;&amp;#039;.  &amp;lt;pre&amp;gt;TAPE = &amp;quot;&amp;quot;  de...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Michael Sipser&amp;#039;s &amp;#039;&amp;#039;Introduction to the Theory of Computation&amp;#039;&amp;#039; describes a quine using Turing machines.&lt;br /&gt;
&lt;br /&gt;
Here is an implementation of the machine &amp;#039;&amp;#039;SELF&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;TAPE = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
def Q():&lt;br /&gt;
    global TAPE&lt;br /&gt;
    TAPE = &amp;#039;TAPE = &amp;quot;&amp;#039; + TAPE.replace(&amp;quot;\n&amp;quot;, &amp;quot;\\n&amp;quot;) + &amp;#039;&amp;quot;\n&amp;#039;&lt;br /&gt;
&lt;br /&gt;
# A&lt;br /&gt;
TAPE = &amp;quot;M = TAPE\nQ()\nTAPE += M&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# B&lt;br /&gt;
M = TAPE&lt;br /&gt;
Q()&lt;br /&gt;
TAPE += M&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt;&amp;gt;&amp;gt; import quine&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; print(quine.TAPE)&lt;br /&gt;
TAPE = &amp;quot;M = TAPE\nQ()\nTAPE += M&amp;quot;&lt;br /&gt;
M = TAPE&lt;br /&gt;
Q()&lt;br /&gt;
TAPE += M&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implementation is complicated by several aspects of the Python programming language:&lt;br /&gt;
&lt;br /&gt;
* Python distinguishes between printing and returning, whereas Sipser&amp;#039;s model of Turing machines just has an output tape. Thus, in Sipser&amp;#039;s quine, part A can just run and leave things on the tape for part B to use, whereas this sort of thing isn&amp;#039;t automatic in Python (if we used separate methods for &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;, then we would have to pass the output of &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;B&amp;lt;/code&amp;gt;, by e.g. calling &amp;lt;code&amp;gt;B(A())&amp;lt;/code&amp;gt;). To emulate this behavior, we use a global variable &amp;lt;code&amp;gt;TAPE&amp;lt;/code&amp;gt; where each part reads from and writes to.&lt;br /&gt;
* Python has local and global variables, so in the method &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; we must explicitly declare &amp;lt;code&amp;gt;global TAPE&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>IssaRice</name></author>
	</entry>
</feed>