2

In Dexter C. Kozen - Theory of Computation (2006, Springer) page 319 exercise 127 he says :

"A set of total recursive functions is recursively enumerable (r.e.) if there exists an r.e. set of indices representing all and only functions in the set. For example, the complexity class P is r.e., because we can represent it by an r.e. list of TMs with polynomial-time clocks."

How exactly do you do what he is talking about for any r.e. collection of functions/languages (or complexity class like P)--enumerate the machines that solve the languages in the collection? Normally, when speaking about an enumerator, you talk about enumerating the words of a language, not a collection of languages.

1 Answers1

3

Kozen answers this in your quote: what you enumerate is Turing machines that accept all languages in P. This makes sense in many contexts, for example if you want to diagonalize against all languages in P.

It is not a priori clear how to enumerate P (as Turing machines). The problem is that given a Turing machine, it is (provably) impossible to tell whether it halts in polynomial time. The trick is to force the machine to halt in polynomial time.

The enumerator goes over all pairs $(T,p)$, where $T$ is a Turing machine and $p$ is a polynomial. For each such pair, it creates a new machine $M(T,p)$ which simulates $T$ for $p(n)$ steps (where $n$ is the input length), and then halts. The machine $M(T,p)$ is guaranteed to run in polynomial time, and so whatever language it accepts is in P. Conversely, for any P-time machine $T$, there is a polynomial $p$ such that $T$ and $M(T,p)$ are equivalent, and so the enumerator goes over all languages in P.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • What I mean is: what is example of code for this is? I'm wondering how the Turing machines are expressed--ie. how do they appear when they are output from the enumerator? –  Jun 01 '20 at 20:16
  • 1
    I'm not sure what you mean by "code". As for how Turing machines are expressed, be imaginative. Whatever you come up with is probably good enough. Essentially, you want a description which could be fed to a universal Turing machine. – Yuval Filmus Jun 01 '20 at 20:17
  • code for such an enumerator –  Jun 01 '20 at 20:19
  • 1
    This sounds like a completely different question. – Yuval Filmus Jun 01 '20 at 20:20
  • 1
    In brief, you enumerate "timed Turing machines", which are Turing machines that stop after polynomially many steps. The enumerator goes over all pairs of Turing machines and polynomials, and converts each such pair to a timed Turing machine. – Yuval Filmus Jun 01 '20 at 20:21
  • The question is "how does an enumerator for machines for languages work?" to me what would be most illuminating is an example, in pseudo-code, of such an enumerator--then I can see an example of how is it outputting / representing these Turing machines--I imagine it's not specifying a 7-tuple for each machine; tho, its describing them succinctly somehow. –  Jun 01 '20 at 20:22
  • 1
    Updated my answer. – Yuval Filmus Jun 01 '20 at 20:25
  • thanks--what do you mean by "It is not a priori clear how to enumerate P (as Turing machines)."? –  Jun 01 '20 at 20:30
  • 1
    This statement is explained in the rest of the paragraph. If it bothers you, just ignore the paragraph. – Yuval Filmus Jun 01 '20 at 20:30
  • ah, I see, read too quickly. Thought you meant it was unclear how to enumerate the Turing machines that you then, in the next step, match with polynomials (by simulating them by that polynomial's number of steps)--thank you –  Jun 01 '20 at 20:31
  • One more question--are the Turing machines, if enumerated this way, unique? It sounds like you would get lots of repeats. Is there a way to do it so each Turing machine is unique? –  Jun 01 '20 at 21:28
  • 1
    They’re not unique, and the definition doesn’t require it. Not sure you can make them unique. – Yuval Filmus Jun 01 '20 at 21:33
  • how can you prove this method "hits" every language in P. How do we know there aren't polynomials or encodings of machines that have been left out? Does the last enumerator have to match every polynomial with every turing machine? Therefor each TM has an infinite number of polynomials paired with it and vice versa, each polynomial has an infinite number of TMs paired with it? Or are there (weaker) different ways to do it? For instance, where each encoding has only a finite number of polynomials paired with it? – DeeDee Jun 10 '20 at 16:39
  • 1
    In the last paragraph I have attempted to prove that this hits every language in P. As for your other questions, there are many possible variants on this idea, which I'll let you figure out on your own. – Yuval Filmus Jun 10 '20 at 19:34
  • Quick question! Can you enumerate over the class P (maybe in a similar way to the way you describe above) so that there is one string of each length that represents a P machine? And i need to be able to quickly (in steps $|s|^k$ for any given $s$ in the enumeration) decode the representation of any machine in the enumeration into a runnable version for the machine (one that can be applied to an input). – DeeDee Jun 18 '20 at 03:13
  • if this is not possible or obvious how to do it, an easier thing to ask might be: can you enumerate over the class $P$ so that there is one string of each length above some length $m$ that represents a $P$ machine? I say above some length because we could start from $|P|min +|T|min= m$ – DeeDee Jun 18 '20 at 03:19
  • 1
    Unfortunately I don’t know how to do that. – Yuval Filmus Jun 18 '20 at 07:06
  • https://cs.stackexchange.com/questions/127346/algorithm-for-enumerating-over-all-possible-pairs-by-size-with-some-added-cond i asked here. Thanks for help! – DeeDee Jun 18 '20 at 14:06
  • last question, promise! can a machine be constructed that simulates all these polynomial machines with no more than polynomial overhead? – DeeDee Jun 19 '20 at 16:46
  • 1
    Your average universal Turing machine has only polynomial overhead. – Yuval Filmus Jun 19 '20 at 16:47
  • sorry just for clarification: for ANY subrecursive indexing of P you can simulate all the P machines expressed as strings, however they are encoded, using SOME machine with only poly overhead? or does it depend on HOW you represent the machines if there exists a machine that can simulate them all with only poly overhead? I didn't mean to lie i count this as same question! lol – DeeDee Jun 19 '20 at 16:52
  • 1
    I don't understand your question enough to answer it. But since the answer would be based on the idea in the answer to your post, I believe that you should be able to answer your question on your own. – Yuval Filmus Jun 19 '20 at 16:53
  • Sorry maybe this is cleaner: for ANY enumeration of p machines (no matter what representation for machines as strings you use) does there exists a TM that can simulate any machine in the list (as they are expressed) with only poly overhead? Or are there some enumerations of P machines that cause this efficient simulation not to be possible based on how they are represented as strings? – DeeDee Jun 19 '20 at 16:56
  • i will try to answer the question thanks! – DeeDee Jun 19 '20 at 16:56
  • https://cs.stackexchange.com/questions/127523/given-an-algorithm-decide-whether-it-runs-in-polynomial-time As D.W. points out in the comments deciding weather a string is an element of your enumeration is a different question than asking weather a given algorithm runs in poly time. I'm just curious, can we decide whether a string is a member of the above enumeration (language representing P) you laid out in poly time? Or can you at least verify one of its strings is a member in poly time? definitely last question! – DeeDee Jun 21 '20 at 22:12