Newsgroups: comp.ai.alife,comp.ai.philosophy,comp.ai,alt.consciousness
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!hookup!newshost.marcam.com!charnel.ecst.csuchico.edu!csusac!csus.edu!netcom.com!jqb
From: jqb@netcom.com (Jim Balter)
Subject: Re: Thought Question
Message-ID: <jqbD4GIA2.5ED@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <3heggdINNrh9@ringer.syd.dwt.CSIRO.AU> <3hg27i$gnd@xmission.xmission.com> <3hsv53$ipj@oznet03.ozemail.com.au> <3hu2u9$dde@romulus.rutgers.edu>
Date: Thu, 23 Feb 1995 14:15:38 GMT
Lines: 69
Sender: jqb@netcom14.netcom.com
Xref: glinda.oz.cs.cmu.edu comp.ai.alife:2555 comp.ai.philosophy:25716 comp.ai:27719

In article <3hu2u9$dde@romulus.rutgers.edu>,
Bill Clark <wclark@romulus.rutgers.edu> wrote:
>Alan Tonisson <tonisson@ozemail.com.au> writes:
>
>>Way back when I was studying at university, a computer science lecturer 
>>challenged us with the problem of either writing a computer program which 
>>prints its own source or proving that it could not be done.  I convinced 
>>myself that it was impossible because it must require some sort of infinite 
>>recursion, but couldn't prove it,

It's dangerous to convince oneself of things one can't prove. :-)  
Can you even begin to outline your thinking, or was it just an intuitive
sort of thing?  The problem with intuitions is that, although they
can be an efficient representation of complex learning, they can also
represent misconceptions and naivety.  To show just how bad this particular
intuition is, consider a special programming language I call "echo".  Actually
it isn't all that special, because an interpreter for it can be found on any
unix system.  The interpreter is called, amazingly enough, "echo".  The really
interesting thing about programs written in "echo" is that they are *all*
self-replicating.  (Ok, for the nitpickers out there, the actual interpreter
is "echo -n" and, on some systems, "echo" programs containing backslashes
are not self-replicating.)

Now, you may say that "echo" isn't the right sort of programming language,
that that's not what you meant.  But then you never said what you meant [Jeff
Dalton would love you for that].  In order to show why self-replication in
"echo" isn't "fair", you would have to start talking about what a computer
program is, what its formal properties are, about programming languages, etc.
You would have to show that the impossibility flows from the definitions, not
just from some mumbo jumbo about "infinite recursion".  In particular, you
would have to ban from your definition of programming language certain sorts
of operations, for instance any operation that prints its own representation
surrounded by legal but otherwise effectless code.  This is getting pretty ad
hoc.  It has nothing at all to do with "infinite recursion", and so I really
wonder at the nature of the arguments [no, Jeff, I don't mean he was screaming
at himself and beating himself up; just rational discourse, y'know] by which
you convinced yourself.

>>but a friend of mine won the challenge and 
>>wrote a Pascal program which prints it's own source.  A few years later when 
>>I was bored I figured out how to do it and wrote one in C.
>>It does not use any data external to itself and, if I remember correctly, it 
>>only uses putc.  I can probably dig it up if it is of interest to anyone.
>
>>I figure that such a program models itself in some sense.

I would say only in the sense of "model" that means "representation".
But not in the sense that means "simulation".  As the term is usually used
here, and as it was being used in this thread, a model of something represents
its *method of operation*.  Self-replicating programs do not in general do so.

>Here's a C example:

[lots of C code, and explanation of Quining.]

Here's a simpler example (actually, it's only to share this, having just come
across it again, that I really posted this note).  It's not strictly
conforming ANSI C since it has a sequence point violation, improper arguments
to main, and illegal ptr<->int conversions, and no prototype for printf (all
these could be fixed in a slightly longer program), but it will work with the
vast majority of C implementations in which ints and pointers are the same
size.  It's fun to watch the infinite recursion vanish before your very eyes
because, while %s acts as a printf format, when interpreted by itself it
represents itself quite well, thank you:

main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}
-- 
<J Q B>

