Construction of a universal prefix-free Turing machine How can one construct a universal prefix-free Turing machine (TM)?  By a universal prefix-free TM, I mean a prefix-free TM $U$ (that is, a TM whose domain is prefix-free) such that for every prefix-free partial recursive function $f$, there feasibly exists $\rho_f$ such that $U(\rho_fx) = f(x)$ for any $x$.
I read the construction by Downey and Hirschfeldt, but I need a detailed construction, partly because I am unfamiliar with the convention in this field.  For example, how can one construct a universal prefix-free TM from a (usual) universal TM?
Thank you for you help in this matter. 
 A: Given input $\rho x$, start by simulating $T_\rho$ on input $x$ until it halts, counting steps. (If it doesn't halt, then just diverge).
Let $n$ be the number of steps it takes for $T_\rho$ to halt on $x$.
Now enumerate all strings $y$ that are either prefixes of $x$ or have $x$ as a prefix and are at most $n$ symbols long. (There are finitely many such $y$s of course). Simulate $T_\rho$ on each of them for up to $n$ steps. If $T_\rho$ halts on one of the $y$s in $\le n$ steps, then diverge!
If none of the $y$s halt within the time limit, then halt with the output of $T_\rho$ on $x$.
It's clear that this works just as a universal machine if $\rho$ is actually a description of a prefix-free machine. On the other hand, the process is prefix-free by construction: it cannot halt on both $\rho x$ and $\rho xw$ because if $T_\rho(x)$ and $T_\rho(xw)$ both halt, the one that does so last will diverge in the above procedure.
A: Here is another way.
Let $p_f$ be a computable prefix code for partial recursive functions. For example, you could let $p_f$ be $0^{|d(f)|}1d(f)$, where $d(f)$ is a description of a turing machine computing $f$. Then given $p_fx$, we can compute $p_f$ and $x$.
Now, let $y$ be the empty string. Now perform the following algorithm:


*

*Enumerate the domain of $f$.


*

*If $y$ is enumerated, check if $x$ is empty. If it is, output $f(y)$. Otherwise, reject (or diverge).

*If $s$ is enumerated, where $y$ is a prefix of $s$, remove a symbol from the beginning of $x$ and add it to the end of $y$, and go back to step 1.



If $f$'s domain is prefix free, then $U(p_fx)$ will compute $f(x)$ if $x$ is in $f$'s domain, and otherwise diverge (which is fine). If $f$'s domain is not prefix free, $U(p_fx)$ will do something else. Either way, $U$ will have a prefix free domain.
