Logic Programming is Underrated
swannodette.github.io
swannodette.github.io
Even programming languages like Prolog needs an expression of the problem that is not exactly how we think in logical expressions. You can't directly translate a first order logic expression to Prolog, you need to add extra thinking before doing that.
On the other hand generic combinatorics libraries don't work with large sets.
Welcome to SMT (satisfiability modulo theories) where there are state of the art optimizations for specific fields. If you want to see something impressive look at how to solve Sudoku with Z3 (http://z3.codeplex.com/) , it's just expressing the problem in logic terms: http://rise4fun.com/Z3Py/tutorialcontent/guide#h210
That said, one thing that I always felt was unique about LP was how one of the primitive operations was data structure unification and how some pieces of code can be run in both "directions" if you are careful. However, I still haven't been able to find a neat example of what sort of problem really benefits from this.
I think one of the clear benefits is having a tool to aid you in your research. Speaking about chess, is like what Kasparov envisioned for advanced chess http://en.wikipedia.org/wiki/Advanced_Chess
2) http://attractivechaos.wordpress.com/2011/06/19/an-incomplet...
For example, imagine that you want to implement a professional chess software. One romantic approach would be to find the best and nicest algorithm(s) to do that. SMT, idealistically, adds some "ugliness" trying to reach to a conclusion using every heuristic available. It's an algorithm too but it doesn't end on a good expressiveness but in inserting every heuristic available inside the resolution process.
The reason logic programming is not widespread is 2 fold:
1) It is a new paradigm (just like functional, object oriented) are new paradigms. That makes it much harder to learn. It is not like going from Java to C#.
Look at this http://dtai.cs.kuleuven.be/ppcbook there are solutions to problems in Prolog. Solutions are amazingly short, and concise. They are beautiful in how succinct they are. But few programmers could produce them. It is just too hard to make incremental updates and debug logic programming.
2) It is not really that useful in real world as a general purpose language. And it is sure not for the lack of trying. It was supposed to be the 5th generation language in Japan, the future, money and brainpower was thrown at it and ... not much happened. People wanted to server data over the networks, render games, search databases, sort data, multiply matrices and in not too many of those domain logic programming screams as "this is the most obvious paradigm". Because it isn't.
And the fact that is 40+ years old actually supports my point. It is so old yet it hasn't caught on yet. Maybe just maybe it is waiting for its time in the limelight and it hasn't come yet... Or is that Bananarama playing in the background, and my Sony Walkman is running out of batteries... ;-)
Isn't logic programming one of the newest programming paradigms out there at about 40 years of age?
There are examples of Imperative, Functional, Object-Oriented and other Declarative programming languages that predate the first logic programming systems from the early 1970's.
When I had a logic programming course at the uni a few years ago, my prof started with an anecdote. He had been teaching the logic and contraint programming course since the years before the "AI winter" of the 1980's, and when he first started it truly was the newest paradigm out there and it was the sexy new entrant to the field. 30 years have passed but no major paradigms have emerged (arguable) so he still begins his course the same way, 30 years later. But with a grain of salt, of course...
The idea of specifying directly what is computed, and not how it is computed, is very useful, and not limited to abuse mathematical problems.
I wrote a bit about that here: http://www.kmjn.org/notes/prolog_lost_steam.html
Logic programming is a wonderful tool to know about, and armed with that knowledge you can adapt your programming style to the problem in question. http://norvig.com/sudoku.html
However some parts of say Prolog are a little unusual. The typical way of writing OR as multiple clauses directly violates DRY and I usually use the alternative IF-THEN-ELSE notation (->). I also use logical loops (basically foreach)...at the end of the day it's kind of a paradigm mix (arithmetic and write sideffects, too).
Grammars and constraints are pretty fun though. It's a very good tool to have in your toolbox. Prolog is certainly the language that expanded my mind the most after having worked with JAVA/Python before.
I believe logicians of philosophical inclination are prone to be enamored with what they have and lose sight of what they don't have. For a good part of two millennia, they kept debating Aristotilean syllogisms, without realizing that classical logic was yet to be discovered. Finally, it was left to the mathematicians to formulate classical logic. The logicians of today are similarly enamored with classical logic without much of an understanding of what it lacks. We would be ill-advised to listen to them. Or, we would be stuck for another two millennia, God forbid. [By the way, the Wikipedia page on Classical Logic is in a pitiful state. I hope somebody will pay attention to it.]
Brilliant new things are happening in Logic. - Mathematicians have formulated Toposes (a generalization of Kripke models), which give us a great new variety of models for intuitionistic logic. There are deep mathematical facts buried in them and continue to be discovered. Toposes and intuitionistic logic are appropriate for modeling computer programs, which live in a growing dynamic world rather than a static one. - Girard has formulated Linear Logic, which broadens our idea of what kind of "things" a logic can talk about. David Pym and Peter O'Hearn invented Bunched Implication Logic, extending Linear Logic with a beautiful model-theoretic basis. These logics applied to imperative programming (which go by the name of "Separation Logic") are revolutionizing the development of technology for imperative programs. It is time to leave behind the classical logic. In fact, we should have done it a long time ago."
- Prof Uday Reddy on the types mailing list.
http://lists.seas.upenn.edu/pipermail/types-list/2013/001684...
Fwiw, answer-set programming is a logic-programming language with a Prolog-derived syntax that has only a declarative reading, and no procedural reading.
A few years ago, I had to help our EEs write some testing software in LabVIEW. The first thing that shocked me was the system was immune to bad data. Secondly, how elegantly it utilized multiprocessing and multithreading hardware.
I wish researchers would work on graphical, signal-based, synchronous languages like this. LabVIEW gracefully solves some of the biggest issues with functional and object oriented languages. Why hasn't more work been done in this area?
Has anyone else had a similar experience?
Check out also the original FBP the article refers to. It seems they had a lot of success with it on the server side of enterprise. seems like it could be ideal for web back end stuff
An analogy: a good programmer should be able to write a state machine. And these are occasionally useful. However, just because a state machine plus a large bidirectional sequential-access data store can do any computation whatsoever[1], does not mean that it is a good idea to write all our programs this way.
Similarly, logic programming and the associated unification operation make up a Turing-complete system, but ... so what? I think that logic programming ought to be available as a library in every programming language. But I don't see the point in making it the only functionality there is.
And, of course, core.logic is an attempt at doing just this for Clojure. (And then there is Pyke ....) However, as this article -- along with the article it references -- notes, we have not really figured out how to integrate logic programming with more mainstream programming methods. This, I think, is a problem well worth solving.
[1] Think "Turing Machine".
Since it's build on the JVM wouldn't it be easier to use one of the existing Prologs and their Java bridges/connectors?
SWI has JPL, GNU/Prolog has something iirc and commerical ones like Sicstus also provide these (Jasper for Sicstus).