AI with Prolog

Prolog is a programming language centred around a small set of basic mechanisms, including pattern matching, tree-based data structuring and automatic backtracking. This small set constitutes a surprisingly powerful and flexible programming framework. Prolog is especially well suited for problems that involve objects - in particular, structured objects - and relations between them. For example, it is an easy exercise in Prolog to express spatial relationships between objects, such as the blue sphere is behind the green one. It is also easy to state a more general rule: if object X is closer to the observer than object Y, and Y is closer than Z, then X must be closer than Z. Prolog can now reason about the spatial relationships and their consistency with respect to the general rule. Features like this make Prolog a powerful language for artificial intelligence (AI) and non-numerical programming in general. There are well-known examples of symbolic computation whose implementation in other standard languages took tens of pages of indigestible code. When the same algorithms were implemented in Prolog, the result was a crystal-clear program easily fitting on one page.

Share

Together with LISP, Prolog is one of most popular Artificial Intelligence programming languages. Prolog was generated by an attempt to develop a programming language that extensively uses expressions of logic instead of developing a program by providing a specific sequence of instructions to the computer.

Prolog is actually used in IBM Watson. Prolog doesn't get much "hype" and "buzz" these days, but it is absolutely still used. As always, it has certain specific areas where it shines, and specific techniques that map well to its use. Specifically, things like Inductive Logic Programming, Constraint Logic Programming, Answer Set Programming and some NLP applications may involve extensive use of Prolog.

Prolog AI Pros and Cons

Pros Cons
Grammars and Language processing Repetitive number crunching
Knowledge representation and reasoning Representing complex data structures
Unification Input/Output (interfaces)
Pattern matching
Planning and Search
i.e. Prolog is good at Symbolic AI

Programming languages are of two kinds:

Procedural (BASIC, ForTran, C++, Pascal, Java);
Declarative (LISP, Prolog, ML).
In procedural programming, we tell the computer how to solve a problem.
In declarative programming, we tell the computer what problem we want solved.
(However, in Prolog, we are often forced to give clues as to the solution method).

Prolog in AI

Prolog has a clear contribution in solving a series of Artificial Intelligence (AI) problems. There are many features that make Prolog suitable as a programming language for developing AI applications. Some of them are:

Prolog in AI
Backtracking Even when a search path ends at a dead end, the backtracking mechanism of Prolog retreats back down the search path to try another path. This feature makes Prolog exceptionally suitable for a number of search problems that AI faces. It also provides the additional advantage of finding more than one solution of the problem, in the case that backtracking is forced, after finding a first solution. Because a great number of AI problems can be represented as a problem of finding the right path in the search space, the built-in depth first mechanism of Prolog, accompanied with backtracking, make Prolog suitable for such applications.
Declarative nature Programming in Logic using Prolog, remove the imperative (serial order) nature of other languages and allow programmer to solve a problem by describing the problem itself rather than defining a solution. The programmer writes programs by declaring the facts and the rules that apply to the problem in hand and then makes queries in order for Prolog to return valid solutions. This high level of abstraction makes Prolog suitable for AI applications where the programmers should give emphasis on the problem itself rather than on the computer idiosyncratic commands that they should impose to the computer system. Prolog’s built-in search mechanism takes the control of the program execution, leaving the programmer to concentrate on the problem itself.
Don’t care and don’t know nondeterminism In the execution of a Prolog program, the nondeterminism feature is really apparent. Although the rule that will execute is the first one that matches the goal, we can ask for more than one solution. Using the backtracking mechanism, alternative rules will apply and other valid solutions will be found. This introduces: a) “don’t know nondeterminism” implying that all possible ways to find the solutions will be followed because the execution does not know how to find the solution, or b) “don’t care nondeterminism” meaning that we just need one solution and we do not care which solution is that among the many that exist. Both of these types of nondeterminsm are considered useful in AI applications, especially for those dealing with logic.
List handling mechanism The data structure of List is very important for handling AI problems (e.g., LISP which is also used for solving AI problems, stands for ” LISt Processing”). Lists are built-in in Prolog while in most other languages they are not, making faster and easier the writing of Prolog programs that require list handling. List’s recursive nature allows the extensive use of recursion in problem solving, providing an additional advantage for solving AI problems with Prolog.
Pattern matching and unification The use of unification to find the most general common instance of two formulas or patterns makes pattern matching a build-in feature of Prolog. This intelligent feature can assist AI problem solving where in many cases the decisions that are made are based on situation matching. This Prolog ability can be found really helpful in specific areas of AI, such as natural language processing, computer vision and intelligent database search.
Recursion, instead of Iteration Because iteration constructs are not provided in Prolog, recursion should be used instead. The simplicity of solving problems recursively makes Prolog programs smaller and understandable even when coping with large, real life AI problems. Additionally, many AI problems are recursive in nature, increasing the suitability of Prolog.

Prolog & Artificial Intelligence Applications

The features described above make Prolog suitable for developing applications that solve AI Problems. Such an area is that of Decision Support Systems. Rules that support decisions can be expressed as Prolog rules, declaratively in pure logic, making development and maintenance of these systems mush easier.

Except from financial decisions, medical decisions can be supported by similar systems written in Prolog. Decision support systems can also take the form of a computer based advisor. Another major AI area that Prolog contributes is that of Natural Language Processing. Pattern matching capabilities and the declarative nature of grammar definitions, make Prolog a handy and powerful tool for processing natural language.

Among the various AI applications using Prolog, many Knowledge-based Systems can be found. This is because, in most of the cases, knowledge in such systems is expressed in the form of rules. These rules can be easily expressed in Prolog syntax. After that, by using unification and Prolog search mechanism, inference can be done.

It is a fact that every AI problem that can be represented using graphs can be handled by Prolog search and backtracking mechanism. Having such an advantage, various Prolog systems have been developed to solve Graph Theory Problems. Another AI area where Prolog is used is that of Scheduling and Planning. The “Generate & Test” technique and the pattern matching mechanism of Prolog, make the test of candidate generated solutions a much simpler task. The unification and pattern matching mechanism of Prolog can also be found useful for AI problems of Computer Vision.

Prolog AI Jobs

These are some positions which can help you have an idea what recruiters are looking for in terms of experience, coding language, education, certificate ... etc.

Prolog AI Jobs
INDEEDIndeed Prolog AI Jobs
MonsterMonster Prolog AI Jobs

Prolog AI Videos

These are some videos related to Prolog and artificial intelligence. Enjoy!

Prolog Code Practice

Would you like to practice your coding skills? Here are some great resources:

Prolog Code Practice
Prolog ProblemsProlog Practice
Prolog ExamplesSample Program & Query

Prolog is a successful logic programming language for developing AI applications. This will not change in the following years, especially with the integration of Prolog with Internet applications and other computer languages such as Java. For example, the JIProlog, a Java platform Prolog interpreter which integrates Prolog and Java languages can add much of the functionality of Java to Prolog making Prolog programs easily delivered through Internet, all over the world. Furthermore, Prolog is a high level computer language that is closer to human than the computer machine. This type of languages is more probable to be used in the future because of the computer science trend of making computers friendlier to the users.

The logic programming features of Prolog make it suitable for developing programs coping with a wide variety of AI problems. The declarative nature of Prolog, accompanied by aspects such as backtracking, unification and pattern matching, recursion, the list handling mechanism and the built-in inference mechanism, provides the programmer with important and useful tools in order to confront AI problems.

Check out our main page for more components of artificial intelligence resources.

Share