15

I learned Prolog many years ago in University. During my professional life, I have never needed to use Prolog. Have I missed something special?

As far as I remember Prolog requires completely different mindset comparing to prominent programming languages.

Is Prolog really ever used to implement something professionally useful?

Nicole
  • 28,111
  • 12
  • 95
  • 143
Gursel Koca
  • 261
  • 1
  • 2
  • 6
  • 3
    Prolog (and poplog) are very good for AI coding. If you're not doing AI related things professionally/seriously, you may not use it at all. Like how a non-engineer may never use MATLAB seriously. – glasnt Feb 23 '11 at 23:14
  • 1
    Good question. Prolog is the first programming language taught in computational linguistics at Uni Potsdam, but after that we don't really use it that much, even if we're quite good at it. It's a pity. Every time I see a question such as "How do I use an accumulator" or "How do I get all possible answers" on StackOverflow, it makes me wonder where the actual professional users are – most stuff seems like homework. Or maybe Prolog proficiency turns you into a robot who never has questions. – Felix Dombek Mar 11 '11 at 02:28
  • I once heard of a system for fault detection written in Prolog and implemented somewhere in Austria (Klagenfurt?) According to what was told to me, the product was quite good and being sold to customers. If you consider this "professionally useful" then the answer is "yes". – Giorgio Jan 14 '13 at 09:10

9 Answers9

12

In my view, learning the basics of Prolog is very worthwhile, irrespective of whether you'll ever use it in the real world. It's also very worthwhile to understand the basic ideas underlying unification, and how a (trivial and inefficient) implementation might be handled.

If you have a problem that would be best solved using declarative logic, you should ideally recognise that and know (if you have the choice) to use the right tools for that job.

However, I agree that Prolog needs a very different mindset from conventional imperative languages, and also a very different mindset from functional languages. Beyond a certain point, it appears to require a lot of experience (just as with anything), and there's even a lot of "textbook" knowledge that makes my brain dribble out of my ears.

My impression is... we are probably both missing something special to a degree, but it wouldn't be practical to dedicate the time to learning even a reasonably complete textbook-level knowledge for Prolog, let alone trying to develop real-world experience, unless you're considering a possible logic programming career.

I've recently been reading a book on AI and expert systems published in 1989 - a lucky find in a second hand bookshop. In significant part, it's a specialised tutorial on Lisp and Prolog. True, most of what it covers hasn't been that impressive for quite a while (search, heuristics etc), but it's still very interesting, and IMO a worthwhile thing to invest a bit of time in.

More recent books that specifically describe Prolog would be better for learning the language, but the risk then is that your brain will dribble out of your ears somewhere in the intermediate-to-advanced material.

  • AI/prolog newbie here. Any online resources you'd recommend? – yati sagade Sep 14 '11 at 19:30
  • @yati - Try http://www.amzi.com/AdventureInProlog/advtop.php - I once ran through a tutorial on the Amzi site which seemed OK as far as I remember, but that was a *very* long time ago. All I've looked at recently (probably the last 5 years) for Prolog is that AI book I mentioned in this answer. You should search for/ask a question here rather than posting comments, especially comments added to answers written by someone who's basically a long-term newbie anyway. Prolog's something I look at rarely and in very little depth - or else I'd have stopped being a newbie a decade or more ago. –  Sep 14 '11 at 22:28
10

This wasn't me, but assuming the question could be "did anyone implement something serious with prolog?" this might count:

http://asmarterplanet.com/blog/2011/02/the-watson-research-team-answers-your-questions.html

Watson is powered by 10 racks of IBM Power 750 servers running Linux, and uses 15 terabytes of RAM, 2,880 processor cores and is capable of operating at 80 teraflops. Watson was written in mostly Java but also significant chunks of code are written C++ and Prolog, all components are deployed and integrated using UIMA.

Kate Gregory
  • 17,465
  • 2
  • 50
  • 84
7

I know A.I. programmers use it.....because I did a Prolog course in my A.I. class but besides that I haven't seen much else said about it. here is a similar question with lotsa answers! https://stackoverflow.com/questions/130097/real-world-prolog-usage

6

Prolog is great for a fast prototyping. For example, in http://www.cri.ensmp.fr/classement/doc/A-381.pdf an SSA-transform for GCC is first implemented in Prolog, and then in C.

I am using Prolog inside compilers for a quick and dirty implementation of type systems, certain optimisations and semantic checks, and I rewrite that Prolog code into something imperative only if its performance is not acceptable.

SK-logic
  • 8,497
  • 4
  • 25
  • 37
2

You answered quite quickly, but I used Prolog in the mid-90s to design insurance rate calculators which would determine for us certain customer segments (read risk) that would fit within premium rates. It is something that you wouldn't necessarily see day-to-day, but surely has affected your P&C premiums over the years.

Jé Queue
  • 3,937
  • 2
  • 29
  • 37
2

According to (This FAQ)1 Parts of Watson, the IBM machine that played Jeopardy, were written in prolog. (see question #6)

GSto
  • 8,531
  • 7
  • 39
  • 59
1

I have used Prolog professionally on a (significant) handful of occasions (diagnostic expert system; HTML transformation; set membership). I have a deep affection for the language so, yes, there's bias here but it's easy to be objective about when Prolog is (more/just as) suitable- you really need to be processing recursive structures; the best example I can give is a relational database table but there are countless other examples (it's probably easier to enumerate counter-examples such as random user input or (most) mathematical functions (however, many mathematical functions do have a recursive structure and hence are perfectly appropriate (discrete fast fourier transform, for example)).

But, of course, very few 'end-to-end systems' can be defined solely in terms of the processing of recursive structures, (exception: theorem proving- but this is a rather academic exercise*) so it's fortunate that a prolog process can be grafted on to a 'more standard imperative process' using all sorts of different techniques (it hardly matters what but a web-service interface is probably generally suitable); so you can deal with the UI, and random event processing etc and then hand-over when necessary (for doing complex database queries or any number of things you might want to do with your recursive structures). I find it works beautifully- better than, for example, LINQ.

So- grab your recursive structures by the sensitive bits and write some lovely, clean, elegant, maintainable Prolog! :)

PS when I'm not using Prolog, I fall back to C#

  • Although, I long for the day when, at least some aspects of, commercial programs are proved correct as a standard practice.
1

Try writing a sudoku solver in your favorite language, then check how it is done in Prolog. In general any CLP problem suits nice with a declarative language like Prolog.

It is also used extensively in formal verification of hardware and software (academically and probably professionally but I don't have any references to companies).

Finally, Erlang is deeply influenced by Prolog, with fault tolerance and concurrency in mind.

sakisk
  • 3,377
  • 2
  • 24
  • 24
0

The software that reads and sorts much of the mail in the US and several other countries is written in Prolog, using a highly optimized compiler. The syntax of mail addresses is written in definite clause grammars, which makes maintenance easy and simplifies adapting the reader to the conventions of various countries and industrial users. Postal services often have complicated sets of rules about things like forwarding addresses, post office boxes vs. street address, etc., and these rules are also formulated in Prolog for easy maintenance.