Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: sci.logic,comp.theory Subject: Re: This is how I solved the Halting Problem Date: Tue, 09 Jul 2019 00:05:59 -0700 Organization: None to speak of Lines: 81 Message-ID: References: <9qGdnS9HpPQroWjBnZ2dnUU7-XmdnZ2d@giganews.com> <87o9248102.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="0f1ff7b5c379c73627a7151f0f8110be"; logging-data="7479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+AS9NE4AmbOFaDiDgxoIhE" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:UDIYdjXtUmZCpMcCa91jTvczDXc= sha1:esXShr1a6v+qVxR1W1Sw1Cy/Z7w= Xref: csiph.com sci.logic:207158 comp.theory:18705 peteolcott writes: > On 7/8/2019 11:57 PM, André G. Isaak wrote: >> On 2019-07-08 7:30 p.m., peteolcott wrote: >>> On 7/8/2019 8:12 PM, Ben Bacarisse wrote: >>>> peteolcott writes: >>>> >>>>> On 7/8/2019 4:40 PM, Keith Thompson wrote: >>>>>> André G. Isaak writes: >>>>>> [...] >>>>>>> So why don't you demonstrate how your actual method works. Show how your >>>>>>> method determines whether the following function halts: >>>>>>> >>>>>>> void DoIHalt { >>>>>>> >>>>>>>      unsigned long x = 14; >>>>>>> >>>>>>>      while (x != 982353739) { >>>>>>> >>>>>>>        x = x * 144; >>>>>>>        x += 17; >>>>>>>        x = x/57; >>>>>>> >>>>>>>      }; >>>>>>> >>>>>>>      return; >>>>>>> >>>>>>> }; >>>>>> >>>>>> Whether that function halts or not is likely to depend on the C >>>>>> implementation. >>>>> >>>>> I already determined that this one does not halt based on a >>>>> repeat in the number sequence. >>>> >>>> You don't know what Keith is saying.  If, as seems likely, the code is >>>> taken to be C or C++ it does not have only one meaning.  The meaning >>>> (i.e. behaviour) depends on the implementation. >>> >>> It does not frigging depend on its implementation. I spent a bunch of >>> hours on that code and found that it specifies a repeating sequence of >>> integers. After I solved it the author rewrote it with integers too >>> large to test. >> >> Of course it depends on the implementation. Keith was pointing out >> that sizeof(unsigned long) is implementation specific, and this code >> will generate different results depending on the value of >> sizeof(unsigned long). > > It really depends on whether or not any of the integers in that > actual computation ever exceed 32-bits. x never gets close to > 32-bits. x never exceeds 76,000,000. This gave me plenty of > room to check for repeats. I ran the program on an implementation with 64-bit unsigned long. x took on values up to 323627088721728065 (approximately 2**64/57). If it never exceed 76,000,000 for you, then you're running on a system with 32-bit unsigned long. Again, the type "unsigned long" does not have the same size in all C implementations. 32 and 64 bits are both common. This affects the behavior of the code. Try compiling with 64-bit unsigned long, or if that's not feasible, modify the code to use unsigned long long rather than unsigned long. (unsigned long long is at least 64 bits, and is exactly 64 bits on every implementation I've seen.) As it happens, the function does not terminate with either 32-bit or 64-bit unsigned long (the values are in a repeating cycle that does not include the tested value 982353739). I was able to demonstrate this in a few minutes by experimentally tweaking the code in a way that depends on the characteristics of this particular program. You claim to have solved the halting problem. If that claim is true, then you should have been able to apply your general method to this program, as you could to any other program, to determine rigorously whether it will halt. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */