lang@bigburd.UUCP (04/22/87)
I recall some discussion in comp.lang.prolog a while back (last summer?) about self-reproducing programs (programs which print their own text when they are run). Did anybody keep that information, by any chance? Does anybody have any references to any literature or any other information about self-reproducing programs? Many thanks. ---------------------------------------------------------------------------- Francois-Michel Lang Daytime phone: (215) 648-7490 Paoli Research Center, Unisys Corporation lang@bigburd.PRC.unisys.COM Dept of Comp. & Info Science, U of PA lang@cis.upenn.edu -- ---------------------------------------------------------------------------- Francois-Michel Lang Daytime phone: (215) 648-7490 Paoli Research Center, Unisys Corporation lang@bigburd.PRC.unisys.COM Dept of Comp. & Info Science, U of PA lang@cis.upenn.edu
keeshu@nikhefk.UUCP (Kees Huyser) (04/24/87)
In article <3248@bigburd.PRC.Unisys.COM> lang@bigburd.PRC.Unisys.COM (Michel Lang) writes: > >I recall some discussion in comp.lang.prolog a while back >(last summer?) about self-reproducing programs >(programs which print their own text when they are run). >Did anybody keep that information, by any chance? >Does anybody have any references to any literature >or any other information about self-reproducing programs? >Many thanks. > >---------------------------------------------------------------------------- >Francois-Michel Lang Daytime phone: (215) 648-7490 >Paoli Research Center, Unisys Corporation lang@bigburd.PRC.unisys.COM >Dept of Comp. & Info Science, U of PA lang@cis.upenn.edu Try the following simple Applesoft Basic program : 10 PRINT "HELLO, WORLD" 20 LIST 30 GOTO 10 I think this is what you were looking for :-) -- Kees | UUCP : keeshu@nikhefk.uucp or {[wherever]!seismo}!mcvax!nikhefk!keeshu | BITNET : keeshu@hasara5.bitnet | FIDO : kees huyser at 28/9 (SagaNet MacBBS) or 500/11 (HCC_Amsterdam_1) | SNAIL : kees huyser, NIKHEF-K, PO Box 4395, 1009 AJ Amsterdam, Netherlands
jaw@ames.UUCP (James A. Woods) (04/24/87)
# "Sixty minutes of thinking of any kind is bound to lead to confusion & unhappiness." -- James Thurber A formal discussion may be found in Hartley Rogers' classic text "Theory of Recursive Functions and Effective Computability", McGraw-Hill, 1967, p. 188-190. The existence of such programs date back to a theorem of von Neumann, though the text uses a consequence of the fixpoint "recursion theorem" of Kleene in proof. More leisurely, one might peek at the European Unix User's Group newsletter (EUUGN vol. 3, no. 4) for the article "Some Self-Reproducing Programs" by Theo de Ridder. Or, for the truly lazy, just compile and run p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);} for a demonstration of such introspective behavior. The 66-byte C version was the culmination of a lively net.sources discussion in 1984. However, some masochists were composing much more elaborate self-reproducing code in FORTRAN at various institutions during the 1950's. -- James A. Woods (ames!jaw)
kees@praxis.UUCP (04/28/87)
In article <3248@bigburd.PRC.Unisys.COM> lang@bigburd.PRC.Unisys.COM (Michel Lang) writes: > > ... self-reproducing programs ... > Some time ago there were some self rep palindromic C programs in comp.lang.c (or whatever it's called). Anyway, here are some things to start with: BASIC: (without line number but that's easy enough) a$="a$=:print(left$(a$,3)+chr$(34)+a$+chr$(34)+right$(a$,4))":print(left$(a$,3)+chr$(34)+a$+chr$(34)+right$(a$,4)) Interpreted BASIC: 10 LIST 10 Algol68: ([]CHARs="([]CHARs="";print(2*s[:10]+2*s[10:]))";print(2*s[:10]+2*s[10:])) BASIC: (self rep palindromic program) 1 ')$a(tnirp:tnirp:txen:;))1,i,$a($dim(tnirp:701ot1=irof:)4,$a($thgir+)43($rhc+$a+)43($rhc+)6,$a($tfel=$a:"1 ')$a(tnirp:tnirp:txen:;))1,i,$a($dim(tnirp:701ot1=irof:)4,$a($thgir+)43($rhc+$a+)43($rhc+)6,$a($tfel=$a 2"=$a 2 2 a$="2 a$=left$(a$,6)+chr$(34)+a$+chr$(34)+right$(a$,4):fori=1to107:print(mid$(a$,i,1));:next:print:print(a$)' 1":a$=left$(a$,6)+chr$(34)+a$+chr$(34)+right$(a$,4):fori=1to107:print(mid$(a$,i,1));:next:print:print(a$)' 1 I haven't tested the last one yet so there may be inaccuracies. The idea certainly is correct. Kees -- ---------------------------------+--------------------------------------------- Kees (Dutch Courage) Goossens | "En nu lieve kijkbuis kinderen: Oogjes dicht kees@praxis.uucp or: | en snaveltjes toe. Slaap lekker!" ...!seismo!mcvax!ukc!praxis!kees | -- Meneer de Uil.
cdsm@doc.ic.ac.uk (Chris Moss) (05/01/87)
Nobody has yet suggested a Prolog program that reproduces itself, so here's a start on the lines of the Basic one: clone :- listing(clone). Any improvements?
broome@brl-smoke.ARPA (Paul Broome ) (05/04/87)
In article <430@ivax.doc.ic.ac.uk> cdsm@doc.ic.ac.uk (Chris Moss) writes: >Nobody has yet suggested a Prolog program that reproduces itself, so >here's a start on the lines of the Basic one: > >clone :- > listing(clone). > >Any improvements? No, except to suggest self-annihilation as an opposite of reproduction. Here's a frivolous little program that removes itself. suicide :- abolish(suicide,0).
schaefer@ogcvax.UUCP (Barton E. Schaefer) (05/05/87)
In article <brl-smok.5829> broome@brl.arpa (Paul Broome (CTAB) <broome>) writes: >Here's a frivolous little program that removes itself. > >suicide :- > abolish(suicide,0). How about this one? The following predicate, invoked as ?- everyclause(everyclause(_,_),X). will remove itself from the database, binding X to a list of all its clauses in the process, then put itself back again. /* `everyclause(X,Y)' returns in Y a list of all clauses whose heads have the same functor and arity as X. `everyclause' works by calling the primitive `clauses', retracting the clause found, recurring to find the next clause, and then re-asserting the retracted clause. It cannot be used to test directly that a list contains every clause; its second argument must be a variable. */ /* Since `clause' fails with an error if called with a variable in its first argument, `everyclause' fails if it would have to make such a call. */ everyclause(X,Y) :- var(X), !, fail. /* The useful part of `everyclause'. */ everyclause(X,[]) :- not clause(X,_), !. everyclause(X,[Y|Z]) :- var(Y), !, functor(X,F,N), X =.. [F|N1], newvars(N1,N2), A =.. [F|N2], clause(A,C), Y = (A :- C), functor(B,F,N), clause(B,D), retract((B :- D)), ((everyclause(X,Z), !, asserta((B :- D))); (asserta((B :- D)), !)). newvars(X,X) :- atomic(X). newvars(X,Y) :- var(X). newvars((X1,Y1),(X2,Y2)) :- !, newvars(X1,X2), newvars(Y1,Y2). newvars([H1|R1],[H2|R2]) :- !, newvars(H1,H2), newvars(R1,R2). newvars(X,Y) :- X =.. [F|A], newvars(A,B), Y =.. [F|B]. -- Bart Schaefer Dept. of CS&E CSNET: schaefer@Oregon-Grad Oregon Graduate Center UUCP: {ihnp4,seismo,sun}!verdix \ 19600 NW Von Neumann Dr {hplabs,ucbvax,decvax}!tektronix !ogcvax!schaefer Beaverton, OR 97006