5 ms·
That makes Prolog look downright useful! I heard from lots of people that it's fun as an esoteric language and some had a homework assignment or two in it, but
by lucb1e 8y ago
That makes Prolog look downright useful! I heard from lots of people that it's fun as an esoteric language and some had a homework assignment or two in it, but nobody really uses it in practice. Do you think this might be more useful as a module to solve logic puzzles, rather than as a complete language by itself? I learned the very basics, but not worked with it enough myself to say whether that would be better than keeping it as a stand-alone language.
- yaantc 8y agoYes, a modern Prolog with CLP(FD) is very well suited to solve logic puzzles. There are many examples on the web, but you can look at this book on ECLiPSe CLP (nothing to do with the IDE, it's a Prolog system with good constraints support): http://www.anclp.pl/ http://www.anclp.pl/ However, nowadays I'd start with Minizinc and its default solver gecode: http://www.minizinc.org/ http://www.minizinc.org/ For combinatorial puzzles it's even easier than Prolog and very efficient. Just read the short tutorial and you should be good to go solving the Zebra/Einstein problem or similar: http://www.minizinc.org/downloads/doc-latest/minizinc-tute.pdf http://www.minizinc.org/downloads/doc-latest/minizinc-tute.p... Minizinc is purely declarative. When more control is needed then you can use Prolog.
- carapace 8y agoWell, the idea that "nobody really uses it in practice" doesn't hold up to the evidence in this thread, eh? It's used and under active development. I think it lacks hype. :-) > Do you think this might be more useful as a module to solve logic puzzles, rather than as a complete language by itself? I was thinking about it this morning and I came to the conclusion that Prolog really is AI. They did it. We have AI already and most of us just failed to notice. The Unification algorithm at the heart of Prolog (I'm not an expert!) is pretty much what your brain does when you solve logical puzzles and problems. We have a machine that can think. The way I think of Prolog is as a super-calculator that can be applied to a huge range of problems and tasks. (One thing to be aware of is that if you have a Prolog-shaped problem and try to solve it in some other language you'll likely wind up reinventing some portion of Prolog in that language! If you look up solutions to the Zebra Puzzle written in other languages you'll see that most of them proceed by implementing some sort of logic solver that resembles a crude Prolog.) There may be practical real-world issues in performance or interfacing for a given application, but in general I'd say that good ol' Prolog is vastly underutilized. (Put another way, we're working harder than we should be.)
- tom_mellior 8y ago> The Unification algorithm at the heart of Prolog (I'm not an expert!) is pretty much what your brain does when you solve logical puzzles and problems. What makes you think that? I don't think we have a clear idea of what the brain does when doing "intelligent" things, but syntactic unification is very probably not it. For whatever it's worth, the CLP(FD) stuff you posted isn't "just" unification, it needs additional powerful constraint solving algorithms behind it to work as well as it does. All that unification does is solve simple equations between terms without knowing anything about what is going on: ?- f(X, b) = f(g(a), Y). % query X = g(a), % solution Y = b. This is nice, but it's not exactly intelligence. Yay for Prolog enthusiasm! I like calling it "magical" too. But let's not go overboard with grand AI claims.
- carapace 8y ago> What makes you think that? Direct observation. I learned unification algorithm from studying Matthew Rocklin's Python Kanren implementation [1]. The next time I was thinking out the solution of a programming problem, as I was witnessing my brain (or mind if you prefer) solve the problem, I realized on a "meta-track" that what it was doing was exactly unification. I actually "saw" it happening and had a context to recognize and name it. I think it helped that I was working in a domain that has models very close to the forms (computer programming) but the rational logical thinking process is the unification algorithm. > I don't think we have a clear idea of what the brain does when doing "intelligent" things Well, I don't mean to suggest that rational thinking is the only kind of thinking! I'm just pointing out that it's a kind of thinking that really has been automated. It's AI. (Not all that AI is or ever will be, but it counts.) Turing essentially made concrete the thought process of solving (some kinds of) math problems, noticed that the "atomic elements" of the process were a finite set, and designed a machine to automate those steps, so in a sense, computers have always been AI. > CLP(FD) stuff you posted isn't "just" unification, it needs additional powerful constraint solving algorithms behind it to work as well as it does. Yes, and the brain has powerful sensory systems attached to it. I think science has identified something like twenty-seven different human senses. These all supply "finite domains" to the reasoning system. The sensory systems are very active, and can function in "virtual" mode (aka imagination) to permit a kind of thinking by simulation (analogs.) Animals have this sort of thinking as well (that's why they can dream.) The linguistic/digital system reifies this fast primary mode thinking into slower rational thinking distinctions and reasoning, which is then used to build coherent models of the world which are then used to generate behavior. [2] If you codify that thinking process you get the unification algorithm. [1] https://github.com/logpy/logpy https://github.com/logpy/logpy [2] ...and behavior generates new sensory inputs... The whole thing constitutes a feedback loop linking the real world with your subjective experience. Linguistic thinking permits direct modeling of recursion, which permits thinking about open-ended loops in behavior in a concrete way, which permits self-referential modification of the reasoning structures, enabling rapid innovation in behavior (aka "culture".) You're a cybernetic process that can become a Gödel machine.