9 ms·
Well, The logic programming language that is used most for real world problems is SQL (the database query language). Now, SQL may be terrible as a logic progr
by joe_the_user 10y ago
Well,
The logic programming language that is used most for real world problems is SQL (the database query language).
Now, SQL may be terrible as a logic programming language (in terms of purity, generality, etc) but it's one of those things where because it's there and it's capacities are good enough for a lot of purposes, it gets used more than tools that one has to go out of one's way to find/use.
Further, note that SQL is widely reviled, partly for it's irregularity but also for the complexity that is inherent to large SQL expressions.
It seems likely to me that if Prolog ever gained the popularity of SQL, there would be umpteen OO packages out there promising to "tame the complexity of Prolog" with one or another OO wrapper, an approach which I assume would leave pure logic programmers aghast.
- mossmoth 10y agoI do not think you are correct in saying that SQL is a logic programming language. A logic programming language is defined in terms of rules/implications[1], which SQL is not. However, it is a declarative language, which Prolog also is. In a declarative language you state what a solution is[2] (which the program then searches for), in contrast to the more traditional type of programming (imperative) that states how to obtain a solution. [1] - https://en.m.wikipedia.org/wiki/Logic_programming https://en.m.wikipedia.org/wiki/Logic_programming [2] - https://en.m.wikipedia.org/wiki/Declarative_programming https://en.m.wikipedia.org/wiki/Declarative_programming
- joe_the_user 10y agoWell, If you look at my whole post, I hope it's clear I'm not trying to say SQL is formally anything, just that it's effectively a logic programming language. IE in an ad-hoc sort-of way SQL can accomplish what a more formal logic programming language accomplish, more or less. You specify a world as a set of tuples and determine whether one set of relations determines another set of relations. That lets you do essentially what prolog can do - for example you can map all the example in the parent article to SQL pretty easily.
- tom_mellior 10y ago> for example you can map all the example in the parent article to SQL pretty easily How would you map the map coloring example? You can model the color table and the neighbor table in SQL, but that's just the data model. What Prolog also gives you is backtracking search. Is there a good way to do that in SQL? I guess it would work by computing the Cartesian product of states and colors and trying a select on that... > You specify a world as a set of tuples and determine whether one set of relations determines another set of relations. That lets you do essentially what prolog can do Datalog, maybe, if you have the search mentioned above. Not Prolog, though: Prolog has terms with free variables and unification. Those have no simple "database" interpretation. The featured article only shows off a small (non-recursive, negation-free) fragment of a Datalog-like language, which itself is only a small (function-free) fragment of Prolog. You can't make broad claims about Prolog from this small set of examples.