A category of computable functions with runtime [category-of-computable-categories-with-runtime]

See: Giorgios Bakirtzis and Christian Williams: Turing Categories. Turing Categories describe _computability_. I want to find a category to work with _complexity_ instead. This is a stab at it. Fix a universal Turing machine and an encoding of the natural numbers. Of course, this lets us speak of _computable_ functions \mathbb {N} \to \mathbb {N} (and these don't depend on the choice of Turing machine). But fixing a specific machine also lets us speak of the _runtime_, in steps, of a program p with input n \in \mathbb {N}. Write p(n) = m if p(n) eventually terminates with output m, and write T(p,n) = t if it takes t steps.

Now we want to define a category as follows:

  • The objects are subsets of the natural numbers.
  • The maps A \to B are equivalence classes of programs under an "asymptotic equivalence" relation.
  • The composition is "the obvious thing".

What I mean by asymptotic equivalence is this: the two programs halt on the same inputs, produce the same outputs, and run in the same amount of time up to a constant factor. To be more precise, p \lesssim p' : A \to B if there exists a constant C so that, when p(n) = m and T(p,n) = t, p'(n) = m and T(p,n) \leq Ct. Then p \sim p' if p \lesssim p' and p' \lesssim p.

This corresponds to our natural definition of "same behaviour, and same O-class".

Now, we want to construct the composition pp' simply to have pp'(n) = p(p'(n)) and T(pp',n) = T(p',n) + T(p,p'(n)). (This means that if p'(n) halts with output m, and p(m) halts with output k, then pp'(n) halts with output k, and has the runtime described above, otherwise it doesn't halt). It's not completely trivial that this is possible - essentially, the "overhead of composition" must be smaller than the runtime of the larger of p and p'. We must add this as a requirement to our Turing machine - luckily, this seems to be satisfied by most sane models of computation.

Call the category so defined \mathrm {Comp}.