I really appreciate articles like this, but almost all Prolog articles seem to cover the same basics. I know that Prolog can be used for bigger programs; does anyone know a tutorial that shows how to e.g. use Prolog to scrape a web page, or provide a dynamic seating chart for your office based on who hates each other, or something like that?
You’re asking two questions here, which lead in very different directions.
One of them, “how do I integrate Prolog with web/database/… stuff”, I can’t really speak to; some Prologs, such as SWI-Prolog, have web stuff built in, but I haven’t really used that functionality.
For the other, “how do I use Prolog for solving non-trivial problems? I’ve seen enough family history chart examples and whatnot…”, I have some suggestions. I’ve used Prolog systems as embedded rules engines on a couple real projects, such as doing automatic electrical grid configuration for architectural planning software. (In my opinion, that kind of thing is really where Prolog shines - when it is used as a rules engine, query language, and so on, rather than a general purpose programming language.) Neither of these books are free web tutorials, but they’re the best sources I’ve found for learning how to use Prolog effectively.
If you’re familiar with the Little Schemer series of books, the closest equivalent is probably Clocksin’s Clause and Effect. It’s a short book, nearly all exercises, and you’ll come away from it with a good understanding of how to apply the Prolog mindset to many kinds of problems. It focuses on core Prolog, rather than any specific implementation. (Prolog is like Scheme, in that there’s a small standard core, but most useful implementations have lots of nonstandard extensions. This will teach to you think in Prolog, you can figure out the rest as you go.)
If working through that has you intrigued, I cannot say enough good things about Shapiro and Sterling’s The Art of Prolog. That book is a study in logic programming, using Prolog as its foundation, and acknowledging its limitations along the way. There are a lot of problems explored, and many projects built up in Prolog; some that are probably a bit awkward (an editor? huh?), but many that are really powerful (e.g. meta-interpreters, including solvers built on top of Prolog). It’s one of a couple books, like SICP, that I periodically dip into and find inspiring. In the same way that you need to learn some Scheme to appreciate SICP, you need a bit of Prolog for TAoP, but it’s well rewarded.
I use Prolog for prototyping things from time to time. For example, I recently wrote out a set of rules for a bootloader and network-based firmware upgrade process in Prolog, using it to figure out if any combinations of states and temporary failures along the way could lead to a bricked device. Even if it wasn’t directly executable, it’d still be a great notation for reasoning about certain kinds of problems. (It’ll also give you a head start on learning Erlang, which is a great language in many of its own ways. :) )
I’ve also heard very high recommendations for Ivan Bratko’s Prolog Programming for Artificial Intelligence from people whose opinions I trust, though my copy is still waiting on my bookshelf. It apparently covers constraint programming, which is a huge strength of Prolog’s, and not covered by the two books above.
I believe Prolog is mostly used in Expert Systems (and some AI, I think), so there may be examples available for that particular field. Given that it’s not a terribly common language it may be difficult to find examples for use-cases outside of its usual domains. If you find one though, please share it!
I’m starting to work through Learn Prolog Now!.
Unfortunately I can’t say it’s what you’re looking for because, well, I’ve just started, but I’m finding it to be good so far.