Hacker News new | ask | show | jobs
by angel_j 2997 days ago
are there any practical uses of quine?
3 comments

Yes: hiding malware.

https://softwareengineering.stackexchange.com/questions/1113...

More generally, https://stackoverflow.com/a/1764933/1462221 points out that DNA implements a very big and complicated quine.

I feel that a groundbreaking use of quines is simply yet to be realized. I have a feeling they will show up in AI (if not intentionally!).

Does DNA encode it's own logic? That seems testable.

One of the answers from your first link gives a link to this excellent article

https://link.springer.com/chapter/10.1007%2F978-3-540-92273-...

on "autocatalitic quines". The Introduction section explains very nice the history of uses of quines in artificial life.

There are some weird parts though in all this, namely that we may think about different life properties in terms of quines:

1) Metabolism, where you take one program, consume it and produce the same program

2) Replication, where you take one program, consume it and produce two copies.

But what about

3) Death

I thought about this a lot during my chemlambda alife project, where I have a notion of a quine which might be interesting, seen the turn of these comments.

A chemlambda molecule is a particular trivalent graph (imagine a set of real molecules, the graphs don't have to be connected), chemical reactions are rewrites, like in reality, when if there is a certain pattern detected (by an enzyme, say) then the patern is rewritten.

There are two extremes in the class of possible algorithms. One extreme is the deterministic one, where rewrites are done whenever possible, in the order of preference from a list, so that the possible conflicting patterns are always solved in the same way. The other extreme is the purely random one, where patterns are randomly detected and then executed or not acording to a coin toss.

Now, a quine in this world is by definition a graph which has a periodic evolution under the deterministic algorithm.

The interesting thing is that a quine, under the random algorithm, has some nice properties, among them that it has a metabolism, can self-replicate and it can also die.

Here is how a quine dies. Simple situation. Take a chemlambda quine of period 1. Suppose that there are two types of rewrites, the (+) one which turns a pattern of 2 nodes into a pattern of 4 nodes, the other (-) which turns a pattern of 2 nodes into a pattern of 0 nodes (by gluing the 4 remaining dangling links in the graph).

Then each (+) rewrite gives you 4 possible new patterns (one/node) and each (-) rewrite gives you 2 possible new patterns (because you glued two links). Mind that you may get 0 new patterns after a (+) or (-) rewrite, but if you think that a node has an equal chance to be in a (+) pattern or in a (-) pattern, then there is twice as possible that a new pattern comes from a (+) rewrite than from a (-) rewrite.

Suppose that in the list of preferences you always put the (+) type in front of the (-) one. It looks that in this way graphs will tend to grow, right? No!

In a quine of period 1 the number of (+) patterns = number of (-) patterns.

Hence, if you use the random algorithm, the non execution of a (+) rewrite is twice more probable to affect future available rewrites than the non-execution of a (-) rewrite.

In experiments, I noticed lots of quines which die (there are no more rewrites available after a time), some which seem immortal, and no example of a quine which thrives.

On practical computers implementing such thing is trivial enough to be borderline uninteresting (at least when done by low-level non-portable means).

The interesting "practical" application is in proving that such a thing can exist in given formal system. By the way the concept of fixed-point combinators (of which Y-combinator is particular implementation) is essentually the same thing. (And in fact such combinators are notionally better match to problem "produce string that contains result of this function applied to it in its contents" than quines)

[Edit: functional->fixed-point and reworded the Y-combinator remark slightly]

As a distraction it can make a nice tonic on a stressful day.