6

Can you give some examples (some trivial and some non-trivial) of computable functions whose inverse is not computable?

user62029
  • 1,764
  • 1
    Why do you think such functions exist? – the gods from engineering Feb 04 '15 at 09:31
  • @RespawnedFluff It's written right here on my book (but it doesn't give any examples, nor am I able to find them). – user62029 Feb 04 '15 at 09:32
  • 4
    Can you provide a detailed reference? I fear you may have misunderstood something. If $f$ is computable (in the classic definition of computability) and injective, you can search its output and invert it in finite time. – the gods from engineering Feb 04 '15 at 09:37
  • @Respawned Fluff: Welcome to the site. I'm sorry if I stole your thunder with my answer. There was another answer that confused me, and I knew your comment was correct, so I wanted to write out the details to help my confusion (and maybe others'). Had there not been any other answer, I wouldn't have expanded your comment into one. – Carl Mummert Feb 04 '15 at 11:58
  • 1
    @Carl Mummert: That's quite ok with me. I wasn't going to detail an answer because I suspect that the OP might have read something rather different (in his book), like that substituting in that statement polynomial-time computable instead of just computable. – the gods from engineering Feb 04 '15 at 12:05
  • Yes, that would change things greatly! @Respawned Fluff – Carl Mummert Feb 04 '15 at 12:06

3 Answers3

4

This is an expansion of the comment by Respawned Fluff. Suppose that $f$ is a partial computable function from $\mathbb{N}$ to $\mathbb{N}$ that is injective. We do not assume that the domain is computable.

Then the graph of $f$ is recursively enumerable - this is the set $G_f$ of all pairs $(x, f(x))$ for which $f(x)$ halts. (See below.)

So the set of pairs $H = (f(x),x)$ is also recursively enumerable - just enumerate $G_f$ but print the tuples in the opposite order. Note that $H$ is the graph of $f^{-1}$.

Now we can use $H$ to compute $f^{-1}$, as follows. Given $y$, enumerate $H$. If a pair $(y,z)$ is ever enumerated into $H$, halt and return $z$. This procedure will produce $f^{-1}(y)$ for every $y$ in the range of $f$, so it will compute $f^{-1}$.


It is a somewhat standard exercise to prove that if $f$ is a partial recursive function, then the graph of $f$ is r.e., and that if the graph of a function is r.e. then the function is partial recursive. This follows from the definition of a partial recursive function:

$f$ is a partial recursive function if and only if there is a Turing machine $M$ such that $f \simeq \phi_M$. That is, $f(x) = \phi_M(x)$ whenever $\phi_M(x)$ is defined, and $f$ is undefined whenever $\phi_M(x)$ is undefined.

So, given an partial recursive function $f$, we may simulate it on each input, and enumerate the pairs $(x,f(x))$ for which $f$ has a value. Similarly, given an enumeration of the graph and an input $y$, we can search the enumeration to see if $f(y)$ exists.

Carl Mummert
  • 81,604
1

Disclaimer:

This is an incorrect example. I'm leaving it here because it might be beneficial to see why it breaks. The explanation is at the bottom.

Example:

Define the domain as

\begin{align} X &= \Big\{ \langle M, I, R\rangle\ \Big|\ R \text{ is the (finite) run of }M \text{ on input } I\Big\}\\ &\cup\; \Big\{ \langle M, I, \bot\rangle\ \Big|\ M \text{ does not stop on input } I\Big\} \end{align}

(the machines in $X$ are deterministic) and define $f$ as $$f\Big(\big\langle M,I,x \big\rangle\Big) = \big\langle M,I\big\rangle.$$

Given a deterministic Turing machine $M$, it has only one run $R$ on any input $I$, and either it stops or not, so $f$ is injective. On the other hand, the inverse function solves the halting problem, so it is not computable.

Why it is incorrect:

The issue is that according to the standard definition the domain of a partial computable function is tied to the function itself, namely, if the computation stops, then that point belongs to the domain. In other words one cannot constraint the domain arbitrarily and that poses problems if the domain we would like to use isn't computable itself.

To summarize, in the example above either:

  • $f$ is computable, but not injective, because there are bad inputs like $\langle M,I,\bot\rangle$ for a machine $M$ that stops on input $I$ that would be mapped to $\langle M,I\rangle$;
  • $f$ isn't computable, e.g. $f$ distinguishes bad inputs from good inputs, but then it is able to recognize $X$, which means it can solve the halting problem.

I hope this helps $\ddot\smile$

dtldarek
  • 37,381
  • 1
    @CarlMummert Something is then wrong, because using $f^{-1}$ you can solve the halting problem: given a machine $M$ and input $I$ calculate $\langle M,I,x\rangle$ and check if $x = \bot$. That would mean $f$ is not computable... – dtldarek Feb 04 '15 at 11:17
  • 2
    I see the issue now, but it is somewhat subtle. It depends on what it means to say that a function is partial recursive. I take that to mean that there is a program $\phi$ such that $\phi(x) = y$ if $f(x) = y$, and $\phi(x) \uparrow$ if $f(x)$ is undefined. For your example, the function $f$ is the restriction of a total computable function to a smaller domain, but the graph of your function is not r.e., so your function is not partial recursive in this sense. – Carl Mummert Feb 04 '15 at 11:25
  • 1
    @Carl Mummert I see, so in this case either $f$ is not injective (some bad inputs map to proper outputs) or is not computable (given an oracle, we can map bad inputs to themselves to make the function injective). – dtldarek Feb 04 '15 at 11:38
  • Yes. But this is a nice counterexample for the next time I teach elementary computability. If we used the definition implicit in this answer, every subset of $\mathbb{N}$ would be "recursively enumerable", because we could start with the identity function $g(n) = n$ and then restrict the domain to an arbitrary subset $X$, and call the resulting function "partial computable". – Carl Mummert Feb 04 '15 at 11:47
  • 2
    @Carl Mummert I agree, I'm leaving my wrong answer undeleted in case someone else had a similar idea $\ddot\smile$ – dtldarek Feb 04 '15 at 11:58
  • (Added while dtldarek was editing): If I understood what Carl Mummert said: you can take any function $f$ that is total recursive and restrict it to some arbitrary subset $D$ of $\mathbb{N}$ such that $D$ is the set of inputs for which a given Turing machine doesn't halt. The graph of $f$ restricted to $D$ is not r.e., but that's because $D$ is not r.e. – the gods from engineering Feb 04 '15 at 11:59
  • Yes - assuming $D$ is not r.e, then if we restrict a total recursive function to $D$, the result cannot be partial recursive. This is somewhat tautological: a set is defined to be recursively enumerable if and only if it is the domain of some partial recursive function (or, if this is not your preferred definition of "r.e.", it is easily equivalent to the definition). @Respawned Fluff – Carl Mummert Feb 04 '15 at 12:03
  • 3
    Indeed, when doing that the new function (let's call it $g$) is basically doing two things in sequence for computing $g(x)$: solving the halting problem for on our chosen Turing machine for input $x$, and after it somehow manages that, it computes the value of $f(x)$. It is an English language infelicity that partial recursive function doesn't just mean taking a total recursive function and making it a partial function in the elementary sense of the latter notion. – the gods from engineering Feb 04 '15 at 12:20
1

No, there is not. Let's $f$ a computable injective function and define the function $g$ such that

$$g(x)=y \Leftrightarrow f(y)=x$$

Then $g$ is effectively computable :

  • On input $x$, simulate the computation of $f$ on all inputs until one of those computations (on input $y$) halts with result $x$. Then return the input $y$.

Note that even if $f$ is not injective or partial, we can still define such a $g$.

Xoff
  • 10,310