CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    2

    Is Halting Problem valid for P (the class of all Pascal programs)?

    Hi All

    I don't know that this is the right place for this post. If it isn't then I am sorry. but I couldn't find any related forum.

    I was discussing halting halting problem with one of my friend yesterday. He asked me a good question. Here is the question:
    "Let P be the class of all Pascal programs that don't use go to ,while and repeat statements, nor recursive procedure calls.Is Halting Problem Valid for P?"

    Now the interesting thing is that halting problem is valid if it has infinite loop and a program can not contain a loop until it has a recursive procedure like goto, while and for loop etc. So I think we can not get halting problem for P (the class of all Pascal programs) that don't use recursive procedure.

    But Still I have confusion in my mind. May be there exist a program which can contain infinite loop without using recursive procedure. I tried to find but I couldn't think any such program. So I want to know "Does anybody know any example in which halting problem is valid even if the program don't use loops and recursive procedure calls?"

    OR if you don't know any example then tell me what do you think about this problem. Is Halting Problem valid for P? If yes, Why?

  2. #2
    Join Date
    Oct 2006
    Posts
    616

    Re: Is Halting Problem valid for P (the class of all Pascal programs)?

    I'm don't really remember Pascal's syntax and rules but if you can manipulate the counter from within a for loop, then you can create an infinite loop, in which case, the halting problem is valid for P.

    On the more theoretical side, if it is not possible to create infinite loops in some language L, then each program in L MUST halt at some point since it has a finite number of instructions, and each loop is performed for a finite number of times.

    Regards,
    Zachm

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Is Halting Problem valid for P (the class of all Pascal programs)?

    Quote Originally Posted by chits12345
    ... until it has a recursive procedure like goto, while and for loop etc....
    OF course not of them are Recursive....but I get your point.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Is Halting Problem valid for P (the class of all Pascal programs)?

    Well, you can create an infinite loop, without any loop structures, just by having two functions that make calls to each other.
    Code:
    Pseudo code:
    func1()
    {
       call func2();
    }
    
    func2()
    {
       call func1();
    }
    
    main()
    {
       call func1();
    }
    Viggy

  5. #5

    Re: Is Halting Problem valid for P (the class of all Pascal programs)?

    Usually, mutual recursion is considered recursion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured