Many thanks to readers who appreciated this article (more than a thousand, so far). However, please note as…
- URGENT: My e-mail address is now omadeon AT hotmail.com; please DO NOT send any e-mail to my obsolete yahoo-account.
A few days ago, I wrote a short posting in this blog about the fact that The ultimate high productivity programming language is PROLOG. A few days later, I was quite astonished to see that this posting became extremely popular! It was listed as no. 35 in the «most popular postings worldwide» list of WordPress a few days ago. (You can click here to verify this claim, scrolling down to no. 35). Meanwhile, some people discussed the Prolog posting elsewhere on the Web. E.g. a discussion in the wiki-site «reddicious», as well as in another blog («The Hungry Brain» – here).
As a result, I will continue to write about Prolog, about why I use it, about the wonderful things you can do in it, and (last but not least) about the fallacy that it cannot be used as a «general purpose programming language«. Well, of course it can be used as a «general purpose language»! This is the philosophy of Visual Prolog -for example- created by an innovative bunch of nice people in Denmark (whom I met personally in a Prolog conference, in April 2006). They created this Prolog dialect and designed it for maximum speed, highest efficiency and ease of use, with a Visual development environment and an object-oriented structure (in the latest versions, 6 and 7). (more about this later, in another posting)
However, today I want to talk about one aspect of Prolog (and many similar Logic Programming languages, e.g. Mercury) that is rarely discussed and very rarely appreciated: The fact that…
PROLOG has (almost) the same Expressive Power as Human Language!
So, what does this mean?
It’s also an issue of practical importance, since you can convert almost any human sentence to a Prolog (logic) representation, which is not a mere (passive) data representation, but a real working program (corresponding to an expression in First Order Logic) which can sometimes produce practical results (e.g. questions or queries in a database or knowledge-base).
One of the most serious challenges for the future is precisely this aspect of Prolog, which makes it possible to convert human text from Web pages to machine-readable representations of it. In fact, today’s Semantic Web initiative is feasible precisely due to some aspects of this conversion, extracting meaningful rdf code from human-text in web-pages, using software such as «Cypher«.
I used the word «almost», because it would be a little silly to convert e.g. poetic or allegorical human sentences to programming code, although it is still possible (to some extent).
Finally, your human sentence(s) must be (in certain ways) complete and consistent, to generate meaningful working Prolog code.
Many years ago, I had written an extension of «PIE» (PDC/Visual Prolog’s open source interpreteter) that was able to convert human sentences (in Greek) to Prolog trees, and from these Prolog trees it generated Prolog code. This was not new, at the time. There were many other Prolog programs converting human text to Prolog code. Of course, such programs typically convert subsets of English to meaningful Prolog code, and human sentences can only be converted if they have a precise (logical) meaning. However, such examples can demonstrate the Expressive Power of Prolog.
Moreover, the old dictionary limitations of only small «subsets of English» being convertible to Prolog, have been overcome by today’s vast machine – readable dictionaries of human language (e.g. Wordnet -click here) and large (open source) knowledge bases of facts about… life and the universe (such as «OpenCyc» -click here).
Well… (you may ask)
– Why aren’t other (procedural) programming languages, as powerful as Prolog (to «understand» human language)?
- Firstly, because they lack the inherent expressive power of Logical Representation, i.e. inference and unification, which are default features of Prolog.
- Secondly, because procedural languages are inherently stupid: They were designed only to do things that are meaningful for a computer; not designed to represent logically… anything that anyone does.
- Thirdly, there is no limit to what can be represented in Logic (and Logic Programming, i.e. Prolog).
E.g. there is no point to convert into ‘C’ or C# or Pascal (etc.) something like «The grandparent of a human is a parent of the human’s parent«. It simply makes no sense, and it can’t correspond to a meaningful (i.e. executable) program. However, in Prolog, you can certainly convert (automatically) the previous sentence to a meaningful, executable piece of Prolog code, e.g.
grandparent(A,X):- human(A), parent_of(A,Parent), parent_of(Parent,X).
If you also tell Prolog that «john, jack and jill are human», as well as «john is a parent of jack» and «jack is a parent of jill», the following Prolog code can be automatically generated (by a simple NLP parser and Prolog code generator):
Now the above lines of code are ready to execute, to get immediately meaningful results, e.g.
Answers: X=jill, Y=john.
Of course, it is because the human sentences had meaning (in real life) that Prolog was able to successfully convert them into meaningful code, able to deliver meaningful results.
However, if you write nonsense, Prolog cannot understand it (but neither can a… human reader)!🙂
Exercises (for the reader):
- Use your… mouse, to access the knowledge accumulated inside the hyperlinks of this posting!🙂
- Use Google (or my bookmarks, or other search methods) to find Prolog programs that can convert subsets of English to Prolog code, and are also able to use this code, to answer human questions (in the same subset of English).
- Read my… next posting!🙂