May 14, 2024 β Back to blog index
In computability, we love to compare the undecidability of problems using reductions: a Turing reduction from π to π is an oracle machine which can solve π when the oracle answers π queries. This directly gives rise to the central concept of Turing degrees.
In complexity, we also love Turing reductions, but they are often too strong. For example, when we get the answer from the oracle, we can easily negate it, so NP is not closed under polytime Turing reductions unless NP = co-NP. To compensate, we use weaker reductions where the algorithm that reduces π to π outputs an equivalent instance of π when given some instance of πΒ βΒ in other words, Turing reductions where there is only a single oracle invocation in βtail callβ position. These are called many-to-one reductions.
Ever since learning about these reductions, I've vaguely wondered why they are code-named βmany-to-oneβ. Why do we stress that such a reduction need not be one-to-one? What does this set-theoretic aspect of the reduction have to do with algorithms? Surely this means that one-to-one (injective) reductions are somehow interesting. Yet nobody ever told me what they could be useful for. Some way to define more fine-grained complexity classes? Some weird cryptography thing where we want to prevent collisions?
Recently, I discovered on Wikipedia what is possibly the only use of one-to-one reductions across all computer science, and, unexpectedly to me, it turns out to be in pure computability. It is a cute theorem which probably deserves to be better known, the Myhill isomorphism theorem. Roughly speaking, it is effective equivalent of the Cantor-SchrΓΆder-Bernstein theorem: if there is a one-to-one reduction from π to π and a one-to-one reduction from π to π, then π and π are isomorphic. Of course, we should define what we mean by isomorphic:
Definition: A redutin from π β β to π β β is a (total) function π : β β β such that β π β β, π β π βΊ π(π) β π. A (many-to-one) reduction is a computable redutin. Two sets π, π β β are computably isomorphic when there is a reduction between them which is a bijection of β onto itself.
[I don't know a term for reductions which are not necessarily computable. By analogy with βrngβ, I took βreductionβ and removed the first two letters of βcomputableβ. Sorry!]
It should be clear that all computability-theoretic notions make no difference between computably isomorphic sets. To justify the term βisomorphismβ, we can view the subsets of β as a category with many-to-one reductions as morphisms. The isomorphisms in this category are exactly as just defined.
Then the theorem reads:
Myhill isomorphism theorem: Let π, π β β. If there are one-to-one reductions from π to π and from π to π, then π and π are computably isomorphic.
As for the proof, it is not very difficult, but quite beautiful. (Update (July 2nd 2024): I've put a short summary of this proof on the Wikipedia article.)
Most proofs of the Cantor-SchrΓΆder-Bernstein theorem revolve around the idea of analyzing βchainsβ which are formed by repeated applications of the two injections. We have sets π and π, injections π : π β π and π : π β π, we start from some π₯ β π, and we consider
Because π and π are injections, these chains do not βoverlapβ. One cannot have two chains starting from different element which eventually merge into a single chain. Each element of π or π is in a unique chain, which continues indefinitely on the right. What happens on the left, if we work backward? As long as we can find an inverse image of the current element, we can continue our travel along the chain. Then three things can happen: either we find an element which is elsewhere in the chain, so we have a loop; or we just continue indefinitely; or there is no more preimage at some point and we are forced to stop. That is, there are three types of chains:
Loops:
π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β β¦ β π₯
Two-sided chains:
β¦ β π^{-1}(π^{-1}(π₯)) β π^{-1}(π₯) β π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β β¦
One-sided chains:
π₯_{0} β π(π₯_{0}) β π(π(π₯_{0})) β π(π(π(π₯_{0}))) β β¦
or
π¦_{0} β π(π¦_{0}) β π(π(π¦_{0})) β π(π(π(π¦_{0}))) β β¦
We can then define a bijection between π and π by pairing elements along the chains. For loops, we just pick an element arbitrarily, pair it with its successor on the chain, and repeat with the next element, until we complete the circle.
π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β β¦ β π₯
For two-sided chains, we form a pair anywhere and propagate forward and backward until eternity:
β¦ β π^{-1}(π^{-1}(π₯)) β π^{-1}(π₯) β π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β β¦
For one-sided chains, we just have to be careful not to leave the very first element unpaired. We start by pairing it with its successor and then continue:
π₯_{0} β π(π₯_{0}) β π(π(π₯_{0})) β π(π(π(π₯_{0}))) β β¦
or
π¦_{0} β π(π¦_{0}) β π(π(π¦_{0})) β π(π(π(π¦_{0}))) β β¦
And we are done. On loops and two-sided chains, our bijection is the same as π or π^{-1}Β βΒ either of them works. The only subtlety is that on a one-sided chain, we have to choose whether to use π or π^{-1} depending on where the first element lives (the blue elements are either paired all with their successor, or all with their predecessor).
Let us now try to prove the Myhill isomorphism theorem. Can we adapt this proof to make it effective? Note that if we pair a blue element with a green element on the same chain, then the mapping we build is a reduction, because we follow π and π, which are reductions. (All elements are now integers, but I am still using green and blue colors to mentally distinguish between elements we think of as in the domain of the bijection we construct and elements in the range.) So, we can reuse the idea of constructing a bijection between the blue elements and the green elements on each chain, and gluing these bijections together.
Certainly, if we are given an element, we can follow the chain in the forward direction, because π and π are now assumed computable. What about the backward direction? Given π₯, we can enumerate integers π and see if we find one such that π(π) = π₯. But what if there is no such π? We just loop until the cows come home. Not good! On one-sided chains, we cannot detect where the chain stops (since we absolutely must halt), so we cannot know the color of the first element.
Intuitively, we seem to only be able to build up the pairs by going forward, since we cannot go backward without stumbling on possible non-termination. If we assume that we have already constructed some pairs, we are happy when we encounter for example
??? β π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β π(π(π(π(π₯)))) β π(π(π(π(π(π₯))))) β β¦
since we can build a new pair:
??? β π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β π(π(π(π(π₯)))) β π(π(π(π(π(π₯))))) β β¦
but our problem is situations like this:
??? β π₯ β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β π(π(π(π(π₯)))) β π(π(π(π(π(π₯))))) β β¦
where we cannot go backward, and the next element forward in the chain is already in a pair. However, there is a nifty solution which should be almost obvious on this visualization. We simply move forward in the chain, until we find an unpaired element, and we pair it:
??? β Β π₯Β β π(π₯) β π(π(π₯)) β π(π(π(π₯))) β π(π(π(π(π₯)))) β π(π(π(π(π(π₯))))) β β¦
And that's basically it! The rest is routine bookkeeping. Our bijective reduction takes an integer π and works by incrementally building pairs (thought of as a blue source and a green target) until it finds π as the source of some pair, at which point it returns the target. In order not to miss any element in the domain or range of the bijection, the pairs are built by enumerating integers π, and for each of them, making sure there is a pair with source π and a pair with target π. If we find that we do not have a pair with source π, we follow a chain from π, skipping already paired elements, until we find an available element, and we add a pair with π as source and that element as target. Adding a pair with π as target is symmetric. QED.
As an added bonus, we obtain that the theorem itself is effective: given algorithms for the reductions π and π, we can compute an algorithm for the isomorphism. Here is some Python code to illustrate this. Beware, as the saying goes, I have only proved it correct, not tested it.
def myhill_isomorphism(f, g):
def iso(n):
paired_sources = set()
paired_targets = set()
for k in range(n+1):
if k not in paired_sources:
paired_sources.add(k)
target = f(k)
while target in paired_targets:
target = g(f(target))
if k == n:
return target
paired_targets.add(target)
if k not in paired_targets:
paired_targets.add(k)
source = g(k)
while source in paired_sources:
source = f(g(source))
if source == n:
return k
paired_sources.add(source)
return iso
I also tried to formalize the theorem in Coq, before eventually giving up as the task was much more work than I anticipated. The biggest problem is that you need to formalize βskipping pairs until an unpaired element is foundβ, which is a while loop, and prove the termination of this loop. On looping chains, this is because the number of nodes is even, and for one-sided or two-sided chains, it is because there are only finitely many pairs already constructed. That βshouldβ all be easy, but the Coq standard library seemed surprisingly lackluster and difficult to useΒ βΒ why are there three different definitions of an injection in unrelated modules and why does each of them prove a different subset of the basic facts about injections? Perhaps I should see if the grass is greener on the Lean and mathlib side.
So much for the proof. Does this theorem really demonstrate that one-to-one reductions are interesting? Clearly, it does not hold as-is for many-to-one reductions. If π and π are many-to-one-equivalent, they may not be computably isomorphic for cardinality reasons. For example, if π = {0} and π = {0, 1}, then there cannot be a bijective reduction from π to π because π has cardinal 1 and π has cardinal 2. The same goes if π = β \ {0} and π = β \ {0, 1}, because of the cardinals of the complements.
The assumption that the reductions are one-to-one prevents these cardinality problems, by the vanilla Cantor-SchrΓΆder-Bernstein theorem. But what if we just require that the cardinalities match? Can we find π and π which are many-to-one equivalent, and between which there is a bijective redutin but no bijective reduction? Can the theorem fail other than for silly cardinality reasons?
From another point of view: In the Myhill isomorphism theorem, we require that the same functions serve as reductions and one-to-one mappings. What if we relax this requirement?
Curiously, I did not find a word about this obvious generalization in any reference about this theorem. (I did find proofs which were essentially equivalent to the one above, but written in a very formal and hard-to-decipher style).
I went searching for a counter-example myself, and in the end I found one, but it is a tad contrived and I remain convinced there must be a simpler one. If you find it, let me know!
Let us first narrow down our search with simple remarks. If π is finite and there is a bijective redutin π from π to π (this means π = π^{-1}(π), which for a bijection is equivalent to π(π) = π), then π is finite with the same cardinal as π, and the two are trivially computably isomorphic (i.e., one can choose π computable). The same goes for co-finite sets. On the other hand, if π and π are both infinite and co-infinite, then clearly there exists a bijective redutin from π to π (glue together any bijection between π and π with any bijection between the complement of π and the complement of π, all these sets being countably infinite).
Therefore, at this point, our objective is to find two infinite and co-infinite sets π and π which are many-to-one-equivalent, but not computably isomorphic. By the Myhill isomorphism theorem, demanding that they are not computably isomorphic is the same as demanding that there be no one-to-one reduction from one of them to the other, for example, no one-to-one reduction from π to π.
I will choose π wisely, and then use for π the set π with its minimum element removed. This construction clearly ensures that π and π are many-to-one-equivalent; the reductions just need to special-case that minimum element and otherwise return the input.
The hope is that, because there is an extra element in π, a one-to-one reduction from π to π is forced to map elements of π to larger elements of π (e.g., map each element to the next one), and we can try to make this transformation non-computable.
If we use for π, say, the halting problem, we unfortunately do not get a counter-example. This is because a reduction from π to π can manage to be one-to-one by a βpaddingβ trick. Intuitively, when we have two instances of π which correspond to the same Turing machine and we want the reduction to map them to different Turing machines, we can artificially make them different, by adding useless isolated states in one of them.
The idea of my counter-example is that if we space out the elements of π enormously, a one-to-one reduction from π to π needs to compute numbers so large that we are able to prevent any computable function from doing the job. This is reminiscent of the busy beaver function.
Assume that we have π and π as specified. Denote π = {π₯_{0}, π₯_{1}, π₯_{2}, β¦} where π₯_{0} β€ π₯_{1} β€ π₯_{2} β€ β¦ (thus π = {π₯_{1}, π₯_{2}, β¦}).
Assume that π is a one-to-one reduction from π to π. It is computed by some Turing machine with a certain number of states π β₯ 1. By injectivity, the π first elements of π, namely π₯_{0}, β¦, π₯_{π-1}, are sent to π distinct elements of π, therefore at least one of them is π₯_{π} or larger. Thus, we have π < π such that π(π₯_{π}) β₯ π₯_{π}.
At last, we can see how to construct π to make this impossible: pick π₯_{0} arbitrarily, and iteratively choose π₯_{π} larger than the maximum image of an π₯_{π} for π < π by a Turing machine with π states. QED.