3 ms·
Pure functional programming? Yeah. But those aren't magic. Whenever you have conditional branching, the halting problem reintroduces itself. (def (collatz-
by vbuterin 13y ago
Pure functional programming? Yeah. But those aren't magic. Whenever you have conditional branching, the halting problem reintroduces itself.
(def (collatz-depth x)
(if (= x 1)
0
(if (= (mod x 2) 0)
(+ 1 (collatz-depth (/ x 2)))
(+ 1 (collatz-depth (+ 1 (* x 3)))))))
is intractable no matter what language you use to write it in.
- steveklabnik 13y agoTotal functional programming is different than purely functional programming: http://en.wikipedia.org/wiki/Total_functional_programming http://en.wikipedia.org/wiki/Total_functional_programming
- vbuterin 13y agoAh okay, interesting, thanks for the link. So it's basically a maximally powerful non-Turing-complete language. I would argue that the section in our v2 whitepaper on non-Turing-complete languages still covers the fallacy behind that: you can still have exponential blowup, so you still need a concept of maximum steps, but then once you have a concept of maximum steps there's little benefit to restricting the programming language.
- emn13 13y agoIn essence, it's just recursion that's only allowed when the recursive input is in some sense strictly "smaller" than its input and therefore necessarily terminates if the input is of finite size and cannot drop below zero. However, it's not magic: it's not automatically trivial to generate such a proof of termination (I'd assume there exist definitely terminating programs for any given proof system that cannot be proven to terminate in that formalism), and it may be a moot point since a slow enough algorithm is for all intents and purposes non-terminating...