4 ms·
The joke.
by lostcolony 5y ago
The joke.
- cies 5y agoSavage. I dont often laugh loud reading HN. Today I did. Thanks.
- cabaalis 5y agoI've only seen Veretasium YouTube video on this a few days ago, and I'm not a mathematician. Is the joke that LLVM has solved the mystery by optimizing out what it decided is an infinite loop?
- junon 5y agoYes.
- Thiez 5y agoThe C++ standard allows compilers to assume that loops terminate. Since there is only one way to exit the loop (`return true;`) the compiler can assume that this line will eventually be reached. Since the rest of the loop has no side effects, the compiler can optimize it out. So the compiler doesn't actually need to figure out if the loop is infinite or not.
- Denvercoder9 5y ago> The C++ standard allows compilers to assume that loops terminate. Technically, it doesn't, but it requires programs to make forward progress, which is defined as either terminating, calling I/O functions, accessing a volatile variable or performing an atomic or synchronization operation. Infinite loops that'll eventually do one of these are perfectly valid C++ and don't have to terminate.
- HelloNurse 5y agoIt optimizes "waste an unpredictable time doing arithmetic without side effects, then return 1" to "return 1 without looking at the input". The relation between that machine arithmetic and the Collatz conjecture is irrelevant.
- Denvercoder9 5y agoI don't think you're responding to the right comment?
- WJW 5y agoLLVM optimizes out the infinite loop, because the C++ standard defines that all programs must be able to make forward progress and so removing this loop does not alter the result of the program. Thus, collatz() as written in the tweet will always return true when optimized by LLVM. This says nothing about the conjecture being true or not, it is solely an artifact of the C++ standard being written a certain way. But also a layer deeper, collatz() takes a uint128 as input and the Collatz conjecture has already been proven to be true for all numbers that would fit into a uint128. So LLVM arrives to the correct answer (`return true`) because of the wrong reason, mathematically speaking.
- ludocode 5y agoThis doesn't exactly follow the Collatz conjecture because multiplication by 3 will be truncated to a 128-bit unsigned int. It is possible that this truncation causes a loop. Even though the Collatz conjecture has been tested for all numbers in this range, it has probably not been tested with this overflow effect.
- plasticchris 5y agoEdit: removing my comment, I misunderstood.
- WJW 5y agoNot so, since the fact that it is in the range does not mean it will steadily go downwards. It might have numbers much bigger than the maximum value for a uint128 somewhere in its Collatz sequence and it is possible (though unlikely) that one of those numbers modulo the maximum value for a uint128 is the original number again. (That is, the modulo operation might introduce loops that are not present in the normal Collatz sequence because mathematical integers don't overflow)
- ColinWright 5y agoAh ... I see my point(s) sailing over your head. I'm guessing you didn't realise that since the joke is presenting this as if it (i.e. "solving" the Collatz Conjecture) were real, I'm replying by treating it as if it were real, and thereby playing along with the joke. Never mind, on-line forums are really the right place for subtlety.
- lostcolony 5y agoOh, I understand your points. But I see the joke sailed right over your head; I'm guessing you didn't realize that this joke is presented as a joke, notably due to the phrase "pack it in mathematicians", since it's quite unreasonable to believe that anyone familiar with the Collatz Conjecture would believe that solving it is the only reason for mathematicians to exist (and also quite unreasonable for anyone familiar enough with LLVM and mathematics to assume a compiler's behavior constitutes a mathematical proof). I can't speak to online forums (I use them for so many things), but I'm sure Twitter is the right place for humor, and not the right place to announce a serious belief you've proved a long standing mathematical problem.
- ColinWright 5y ago> "Oh, I understand your points. But I see the joke sailed right over your head ..." OK, I guess my sense of humour hasn't translated into your context. Clearly my comment makes you think I didn't get the joke, but I did. > "I'm guessing you didn't realize that this joke is presented as a joke, ..." Oh, I did. Really, I did. I guess we're just talking past each other. <shrug> You didn't get my joke, probably because you think I didn't get the original. Time to give up.
- lostcolony 5y agoOkay. I'm not sure dissecting the technical inaccuracies of a joke ("but an imam would never walk into a bar!") is itself a joke (and I'm pretty sure you edited the comment just above to agree it was a joke, but maybe I just didn't read it closely enough), especially when you'd give the exact same response if you didn't know it was a joke, but did know it was technically incorrect, but fair enough.