Skip to main content

The Grzegorczyk Hierarchy

Now to the other end of the subject, computational complexity. The two ends aren’t going to meet in the middle, but the Grzegorczyk Hierarchy is so simple it should be at the start by natural justice, and it’s good to have in mind as a pleasant ending point while getting lost in pregroup theory.

If you want to ask yourself whether a problem is computable or not, you have to define what you mean by ‘computable’. It’s left as an exercise for the reader, basically. So the popular thinking is that effectively computable functions and recursive functions are the same thing – that is, every computable function should be recursive.

Furthermore, a slightly smaller class of functions, the primitive recursive functions, contains pretty much everything anyone’s interested in, and leaves out horror shows like the Ackermann function.

The idea is that you can start with a few really simple initial functions: zero; successor; projection, and the operations of composition and recursion, and end up with pretty much every function on the natural numbers that anyone’s ever thought up. (( before this was claimed and people tried to think of things that weren’t included in this class, anyway ))

A primitive recursive function is one which can be defined by finitely many compositions and recursions on the initial functions. A generally recursive function can be defined using unbounded minimisation as well, but remember that we’re deliberately ignoring those.

Basic building bits

These are the functions we’ll begin with:

  • o(x)=0, the zero function
  • s(x)=x+1, the successor function
  • pni(x1,,xn)=xi, the projection function pni is an (n)-ary function which gives you the ith parameter passed in to it.

The projection function just gets round the problem of functions having different arities – different numbers of arguments. Real Red-Blooded Americans like Haskell Curry did everything with only unary functions in λ-calculus, but we’re just in this for the money, so we can fudge things. From now on I’ll leave it up to you to decide how many parameters a function should take, and complaints of “that function doesn’t take that many parameters!” will fall on deaf ears.

Ok, so you’ve got your initial functions. Now I’ll let you define new functions by composing two you’ve already got together, so something like h(x)=f(g(x)), and by using recursion. We can write these as operators so that they fit in nicely with the others when written down:

  • h=C(f,g1,,gm) means that h(x1,,xn)=f(g1(x1,,xn)),,gm(x1,,xn)).
  • h=R(f,g) means that h(x,0)=f(x), and h(x,n+1)=g(x,n+1,h(x,n)) (( Note that the definition defines for n+1 in terms of n, instead of n for n1. Also notice that we haven’t used any subtraction at all yet. It’ll appear eventually as a weird byproduct of addition. Finally, adjust this definition yourself for n-ary functions f ))

The idea with recursion is that you add an extra parameter n to your function, and define it entirely at n=0 using some other function you’ve got. You then define your function at any further n+1>0 by sending all your parameters and the value computed at the previous n. It’s a bit like induction – any particular value of the function exists because all the previous ones do, and you can get it by starting at n=0 and computing upwards.

Complexity

Now we ask ourselves about complexity. Some functions are definitely harder to compute than others, so how do we define that in a rigorous way? Let’s look at the way functions are made – by composition or by recursion. Composing two functions together can only take as long as working one out then the other, so the time of computation is still on the same order of magnitude as the composed functions. Recursion, however, could entail an arbitrary number of computations of the basic functions, so this is the thing I think we need to pay attention to.

Simply counting the number of recursions involved in the definition of a function would be the obvious way to start, but how about h=R(f,g), where f uses two recursions and g uses three? How many recursions should you say h uses? I’m not totally sure why it’s complicated, but that’s probably something to do with it.

Anyway, a different angle of attack is needed, and a clever Polish mathematician thought of one.

The Grzegorczyk Hierarchy

The start

We’ll start with the initial functions, and try to create the class of all functions that are about as complicated as they are.

This class will be closed under composition, because we’ve decided composition doesn’t count for much. By composing the successor function with itself, we can get fa(x)=x+a, for any constant a. Throwing the zero or projection functions on top of these wouldn’t get us anywhere further, so the add-a-constant functions are the only ones we can get so far. Projection’s particularly useless because we’ve only got unary functions at the moment, so no way to sensibly define anything on multiple parameters.

Clearly allowing any recursion would get you the whole class of primitive recursive functions in one sweep, so I’ll say that you can define new functions by recursion, but only if they are bounded everywhere by some other function you’ve already got. So, a function g(x) is allowed only if you’ve already got some other function f(x) such that g(x)f(x),x.

The class we’re creating is closed under bounded recursion. This doesn’t actually get us all that much. For example, we can’t have the addition function, because there is no constant a such that x+y<x+a,y. In fact, bounded recursion doesn’t get us anything new at all here, it only becomes useful later on. I just included it here so you don’t complain about my classes not all looking the same at the end.

Boring starting class defined, let’s call it E0

The hierarchy

What was holding us back in E0 was the want of a bigger function, so let’s define one and see what else that gets us. The choice of this function is entirely arbitrary, so let’s go with addition, but give it a funny name:

e0(x,y)=x+y.

What can we get now? Well, we can add arbitrarily many number together to start with, since x+y+z=(x+y)+z, or, in our terrifically laboured notation using the initial functions and composition, add3(x,y,z)=C(C(e0,p31,p32),p33).

So taking E0 and this new function e0 and closing the whole lot under composition and bounded recursion gives us a new class of functions which is a superset of the previous one, and contains things which definitely look more complicated than what we had before. An idea is born!

If we define suitable en for any n, we can create a hierarchy of functions which is increasing in complexity. Here’s my choice of the en:

e1(x)=x2+2en+2(0)=2en+2(x+1)=en+1(en+2(x))

Finally, we say that En+1 consists of all of En, plus en, closed under composition and bounded recursion.

Tedious souls can show that all of the elementary functions reside in E3, and that a whole plenoply of mathematical operations you know and love fit in thereabouts. Particularly, bounded minimisation makes a welcome appearance.

It turns out that the union of all the En is the class of primitive recursive functions, so we’ve done what we wanted to do – every computable function we could reasonably want to look at lies on some finite level of this hierarchy, representing an impression of how computationally difficult it is. Super!

References

Kevin Kelly’s lecture notes

Computability and Unsolvability, Martin Davis