I am trying to define the Ackermann-Peters function in Coq, and I\'m getting an error message that I don\'t understand. As you can see, I\'m packaging the arguments a,
You get this error because you are referencing the ack function while you are defining it. Self reference is only allowed in Fixpoints (ie. recursive functions) but the problem is, as you probably know, that the Ackermann function is not a primitive recursive function.
See Coq'Art section 4.3.2.2 for some more information on this.
So one alternative way to define it is by inlining a second recursive function that is structurally recursive for the second argument; so something like
Fixpoint ack (n m : nat) : nat :=
match n with
| O => S m
| S p => let fix ackn (m : nat) :=
match m with
| O => ack p 1
| S q => ack p (ackn q)
end
in ackn m
end.