<p>​​A <a href="https://rosettacode.org/wiki/Quine" rel="nofollow noreferrer">Quine</a> is a (non-empty) program <span class="math-container">$P$</span> that takes no inputs and returns its own source code <span class="math-container">$\langle P\rangle$</span> as the only output. For a function <span class="math-container">$f$</span> (with appropriate domains and range) define an <span class="math-container">$f$</span>-Quine as a program <span class="math-container">$P$</span> that takes an input <span class="math-container">$x$</span> and outputs <span class="math-container">$f(\langle P\rangle, x)$</span>. Thus, with no inputs and when <span class="math-container">$f = id$</span> we recover the standard notion.</p>
<p>Given a source code <span class="math-container">$\langle f\rangle$</span> for <span class="math-container">$f$</span> in some programming language is it possible to efficiently compile it into an <span class="math-container">$f$</span>-Quine in the same language? I think this would amount to making <a href="https://en.wikipedia.org/wiki/Kleene%27s_recursion_theorem" rel="nofollow noreferrer">Kleene's recursion theorem</a> very concrete.</p>

CC BY-SA 4.0
2023-06-10T10:17:54.627Z
The standard proof of the recursion theorem is perfectly constructive and explicit: let $Q$ be a program that takes as input the code $\langle R\rangle$ of a program with one input, and outputs the code of the program $f(\langle R(\langle R\rangle)\rangle,x)$ (that is, hardwire the input $\langle R\rangle$ into $R$, and hardwire the code of resulting program into $f$). Then put $P=Q(\langle Q\rangle)$.
Emil Jeřábek
CC BY-SA 4.0
2023-06-16T17:05:25.550Z
Hi there!  When I was a grad student, I implemented something like this for fun and it seems to still work.  It makes self-referential webpages.  If you're interested, see here: http://michaelwehar.com/quines/howto.html  Maybe we could collaborate to make a more refined version of this in the future.  :)
Michael Wehar
CC BY-SA 4.0
2023-06-16T17:06:36.627Z
Here's the program that builds "f-Quines" for you: http://michaelwehar.com/quines/self_reference_made_easy.html
Michael Wehar
CC BY-SA 4.0
2023-06-16T17:11:17.623Z
For more explanation, when you define G(x,y), x refers to the webpage's own source code and y refers to the input that will be put by the user into the generated webpage's textbox.  It then outputs the code for a webpage with the textbox that takes in y as input and evaluates G(e,y) when you click the button where e is the webpage's own source code.
Michael Wehar
CC BY-SA 4.0
2023-06-16T17:14:22.353Z
To better understand, as an example, you could type in "console.log(x);" and click generate.  Then you could create a webpage with the generated code.  This webpage will print its own source code to the console and ignore the input y.
Michael Wehar
<computability><fixed-points>
Generalizing Quines: Outputting an Arbitrary Function of Source Code
Pooya Farshim
# Generalizing Quines: Outputting an Arbitrary Function of Source Code

(Asked by: username_0 on 2023-06-09)

​​A [Quine](https://rosettacode.org/wiki/Quine) is a (non-empty) program $P$ that takes no inputs and returns its own source code $\langle P\rangle$ as the only output. For a function $f$ (with appropriate domains and range) define an $f$-Quine as a program $P$ that takes an input $x$ and outputs $f(\langle P\rangle, x)$. Thus, with no inputs and when $f = id$ we recover the standard notion.

Given a source code $\langle f\rangle$ for $f$ in some programming language is it possible to efficiently compile it into an $f$-Quine in the same language? I think this would amount to making [Kleene's recursion theorem](https://en.wikipedia.org/wiki/Kleene%27s_recursion_theorem) very concrete.

**Tags:** computability, fixed-points
> **Comments:**
> **username_1**: The standard proof of the recursion theorem is perfectly constructive and explicit: let $Q$ be a program that takes as input the code $\langle R\rangle$ of a program with one input, and outputs the code of the program $f(\langle R(\langle R\rangle)\rangle,x)$ (that is, hardwire the input $\langle R\rangle$ into $R$, and hardwire the code of resulting program into $f$). Then put $P=Q(\langle Q\rangle)$.  
> **username_2**: Hi there!  When I was a grad student, I implemented something like this for fun and it seems to still work.  It makes self-referential webpages.  If you're interested, see here: http://michaelwehar.com/quines/howto.html  Maybe we could collaborate to make a more refined version of this in the future.  :)  
> **username_2**: Here's the program that builds "f-Quines" for you: http://michaelwehar.com/quines/self_reference_made_easy.html  
> **username_2**: For more explanation, when you define G(x,y), x refers to the webpage's own source code and y refers to the input that will be put by the user into the generated webpage's textbox.  It then outputs the code for a webpage with the textbox that takes in y as input and evaluates G(e,y) when you click the button where e is the webpage's own source code.  
> **username_2**: To better understand, as an example, you could type in "console.log(x);" and click generate.  Then you could create a webpage with the generated code.  This webpage will print its own source code to the console and ignore the input y.  

---

## 0 answers

