Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Halting Problem in ordinary C ?

polcott

Active Coder
Code:
typedef void (*ptr)();
int HHH(ptr P);

void Infinite_Loop()
{
  HERE: goto HERE;
  return;
}

void Infinite_Recursion()
{
  Infinite_Recursion();
  return;
}

void DDD()
{
  HHH(DDD);
  return;
}

int DD()
{
  int Halt_Status = HHH(DD);
  if (Halt_Status)
    HERE: goto HERE;
  return Halt_Status;
}

Every sufficiently competent C programmer knows
that when HHH correctly emulates N steps of the above functions that none
of these functions can possibly reach their own "return" instruction and terminate
normally.

Since HHH does see that same pattern that competent C programmers see
it correctly aborts its emulation and rejects these inputs as non terminating.

Fully operational software system enabling any C function to emulate the x86
machine code of another C function in debug step mode.
x86utm/Halt7.c at master · plolcott/x86utm

This x86utm operating system allows the emulator to emulate itself emulating
another C function to arbitrary levels of recursive emulation. It is on this basis
that termination analyzer HHH is created.
 
What would your simulator say about the monkeys and the typewriters?

Function X creates random books until Hamlet is produced. It will halt eventually.

Function Y randomly tests Fermat's theorem until a counter-example is found. It will never halt.
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom