Prolog is brilliantly useful for text processing and reasoning about strings, mostly due to its built-in grammar formalism called <i>Definite Clause Grammars</i> (DCGs).<p>In fact, Prolog originates from <i>Q-systems</i> which were specifically designed to process language via grammar rules:<p><a href="https://en.wikipedia.org/wiki/Q-systems" rel="nofollow">https://en.wikipedia.org/wiki/Q-systems</a><p>The "Q" stands for Québec, where Alain Colmerauer developed this formalism which eventually led to Prolog. A recently released documentary talks a bit about these developments:<p><a href="https://youtu.be/74Ig_QKndvE" rel="nofollow">https://youtu.be/74Ig_QKndvE</a><p>It is interesting that the very first Prolog systems, Prolog 0 and Marseille Prolog, represented strings as lists of characters, then the Edinburgh tradition used lists of <i>codes</i> (in the implementation defined encoding), and all Prolog systems that have become available in the last 5 years (Scryer Prolog, Tau Prolog, Trealla Prolog and ichiban/prolog) are again using lists of characters to make string processing as convenient and readable as originally intended.<p>For example, we can use definite clause grammars in Scryer Prolog to find occurrences of the same character twice in immediate succession in a string:<p><pre><code> ?- phrase((...,[C,C],...), "Hello, world!").
C = l
; false.
</code></pre>
In this string, the character 'l' is the only such letter.
I remember reading and re-reading that article back when it first appeared on the 'net, right after I graduated from CompSci with a big crush on Prolog, paired to gigantic gaps in my understanding of it (and of Logic Programming in general).<p>The article looked... not enough. I got a general idea of how Prolog was used in Watson, but not clear enough that I could easily reproduce it myself. Or so I thought back then.<p>Reading it again now, it's clear to me that they used Prolog to implement the rule-based part of their system, whose function was, essentially, to map from an initial parse of a Jeopardy qustion to a semantic representation of the question, then find an answer for it.<p>Similar to what Triska points out in another comment in this thread, this is Prolog's bread and butter and the kind of thing that modern AI approaches can still not do very well, or at all. The downside of course is that they had to encode all those rules in Prolog by hand.<p>Which is not strictly necessary thanks to Inductive Logic Programming approaches, that can learn Prolog programs from data, either on their own, or in an interactive session, collaborating with a human programmer. I hear that IBM now have a dedicated ILP team who seem to be working on problems like that. Let's hope that the Watson debacle doesn't drag the whole thing down with it.