Sunday, 31 January 2010

Quines again + SRH (getting there)

Here are Quines for the Euphoria programming language:

sequence quine
quine="sequence quine%squine=%s%s%s%sputs(1,sprintf(quine,{13,34,quine,34,13}))"
puts(1,sprintf(quine,{13,34,quine,34,13}))

and php:

<?php
$quine='<?php%c$quine=%c%s%c;%cvprintf($quine,Array(13,39,$quine,39,13,13));%c?>';
vprintf($quine,Array(13,39,$quine,39,13,13));
?>

which I felt inspired to do last night. These are easy because of the built in ability of both languages to generate a string template and then substitute in values later (the two printf flavours).

I still can’t quite get my head around what the exact nature of the problem is so I’ll analyse it here. I did cheat when I initially found this problem and read someone’s take on Quines – he explained that the secret was to create a copy of the program in memory and then essentially print this twice – once for the whole program and then once for the memory definition itself. So this idea of the solution isn’t mine. It makes me wonder whether there are other solutions.

It was harder in BASIC because without being able to natively substitute, one imagines the solution is this (quoted section underline):

a$=“a$=”+Chr(34)+“a$=”+Chr(34)+“+Chr(34)+”+Chr(34)…

Every time a “ character is met the string needs to stop and add a Chr(34) as a meta command (outside the string). The code to do this involves two “ characters: 1 to stop the string quotation and 1 to restart it again. Thus every time a “ exists in the code it requires 2x” to encode it. Obviously an infinite process. This is not how to do a Quine in BASIC! One solution I imagine is to use another character which is not used in string definition and then substitute it after the string has been generated.

This is an example of SSR (strong self-reference). A string is defined using the “ characters. To then ask a string to encode itself then requires it to encode the “ characters. There is then an ambiguity. Are the “ characters defining a string or are they part of a string? This is strong self-reference (SSR) – the string is not about itself it is actually itself. Two levels are implied by SSR. To encode the “ characters requires a different system of interpretation to avoid ambiguity. Thus 2 levels of interpretation are required. One level interprets “ around text as the definition of a String entity, the other level interprets “ as just a character and part of the String entity.

It is this requirement of 2 levels which is essential to SSR which is what I think I’ve called is the God argument. For any system to manipulate itself it need to approach itself in a meta level of interpretation. Self-reference generates levels. Thus any system available to manipulation requires a higher level … Mankind needs the God level if he is to approach reflection upon himself.

However two levels can lead to infinite recursion as seen in the basic example because every time the lower level meets itself it must invoke the higher level which expands the complexity of the system. Thus becomes “ + Chr(34) + “ (where defining characters with numbers and the Chr() function is a higher level outside the world: the meta ‘deus ex machina’ (i.e. God) of the String world). If that expansion involves the lower level then it will expand forever. That is one way to solve the BASIC Quine: shift the whole problem into the higher level and use Read and Data statements.

This as far as I know is existence of the Meta level is the same argument as God-el himself tried to rigorously formulate. I’ll need to find out more about Godel to confirm that. If it turns out he already had the idea then I doubt very much I’ve more to add to his genius work!!! It is the essence of the SRH intuition that I sought two years ago now to try and marginalise materialism.

ref BBC Dangerous Ideas (You-Tube)

No comments:

"The Jewish Fallacy" OR "The Inauthenticity of the West"

I initially thought to start up a discussion to formalise what I was going to name the "Jewish Fallacy" and I'm sure there is ...