The purpose of this question is to determine the minimum correct halt status criteria required to detect infinite recursion, when we assume that the functions involved are pure functions (thus computable functions).
#include <stdint.h>
typedef void(*ptr)();
void X(ptr P, ptr I)
{
P(I);
}
void Y(ptr P)
{
X(P, P);
}
int main()
{
X(Y, Y);
}
Does that fact that Y calls its caller with the same parameters as its caller prove that Y is calling X in infinite recursion?
When we assume that Y is a pure function
If there were any conditional branch instructions in Y prior to its call to X it seems to be proved that they didn't make any difference.
In computer programming, a pure function is a function that has the following properties:
(1) the function return values are identical for identical arguments (no variation with local static variables, non-local variables, mutable reference arguments or input streams), and
(2) the function has no side effects (no mutation of local static variables, non-local variables, mutable reference arguments or input/output streams). https://en.wikipedia.org/wiki/Pure_function
Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do the job of the function, i.e. given an input of the function domain it can return the corresponding output. https://en.wikipedia.org/wiki/Computable_function#
Caveat: I've never done a formal proof before, but I'll make an attempt using code equivalent substitutions that I understand.
Summary of steps:
In the final step,
maincallsX. And,Xjust calls itself [infinitely].UPDATE:
I'm not totally sure I understand what you're requesting. But, I think it's implied by [or a byproduct of] the proof above.
Perhaps, if we redo step (5) as:
Now, we can try:
We end up with a calling sequence:
I don't know, but it may be more clear if we branched off after step (3) and changed
mainfromX(Y)toY(X)