# Theory of Turing machine which outputs Turing machine?

I understand the notion of the universal Turing machine ($U$), which receives a pair of Turing machine ($M$) and an input to $M$ ($x$). If $M$, which obtains $x$, outputs $y$, $U$, which obtains $(M, x)$, outputs $y$ as follows:

$M: x \mapsto y \\ U: (M, x) \mapsto y$

My question is whether there is a theory of another type of Turing machine where the output (not input) of Turing machine is another Turing machine like:

$U': x' \mapsto M$

I guess a program which generates another program can be regarded as this kind of Turing machine $U'$. If so, automatic code generator and machine learning algorithm might be regarded as this type of Turing machine.

(Maybe, brains of human programmers can be modeled using a theory of such Turing machines because a source code seems a form of Turing machine.)

• Like, every functional programming language? I'm confused by this question. You seem to accept that Turing machines can be represented as numbers (you should really write $\langle M \rangle$ as input), numbers can be the ouput of a TM, so: yea, of course that's possible! In the standard theory. – Raphael Aug 29 '17 at 4:47
• @Raphael Of course, I understand Turing machine can output another Turing machine. My concern is whether there is a (interesting) theory about such Turing machine. Turing machines receiving (<M>, x) can be the Universal Turing machine, which has very interesting properties. I'd like to know whether there is interesting theory about Turing machine providing another Turing machine. I guess machine learning or automatic coding are candidates. – rkjt50r983 Aug 29 '17 at 11:09
• I'm afraid that's way too broad then: there are many, many instances of such behaviour. Community votes, please! – Raphael Aug 29 '17 at 13:53
• @rkjt50r983 Yes, recursion theory, or computation theory studies this in details. See, for an example, the $s_{mn}$ theorem for a starter. – Pål GD Aug 29 '17 at 14:33
• Have you tried to make any such interesting machines outputing machines by yourself? – Andrej Bauer Aug 29 '17 at 20:39

Something which is closely related to what you are referring can be the field of Program transformations, which tries to study systematically programs that modifies other programs. The original interest of this field is the transformers that are semantically invariants (with a bit of hand waving: you want to study transformers $T$ such that for any program (or a TM) $p$, $T(p)$ does the same thing as $p$). Derives from these original considerations the subfield of program synthesis (here, given some input datas, you want to automatically generate a program that satisfies some conditions encoded by you input).