DEV Community

Cover image for Learning Pilog - 1: A Short Introduction to Prolog

Posted on • Originally published at

Learning Pilog - 1: A Short Introduction to Prolog

Before we actually start off with Pilog, I thnk it will be good to take a few minutes to talk about Prolog, which is the basis of Pilog.

A brief history of PROLOG

The Prolog programming language appeared in 1972. It was developed and implemented in Marseille, France, by Alain Colmerauer and Philippe Roussel, in collaboration with Robert Kowalski of the University of Edinburgh. Even today two main dialects, one originating from Marseille, one from Ediburgh, exist.

Prolog had a major role in the 1980's in the development of expert systems and artificial intelligence. In 1982, the Japanese government launched the Fifth Generation Computer Systems Initiative, aiming to lead the world in artificial intelligence and smart machines, and the chosen tool to meet this target was logic programming. As reaction to that, a similar European project called Esprit was launched, both of them leading to an increased research and development into Prolog.

Fun fact: Lisp was developed in the US, while Prolog was developed in Europe, and this lead to a kind of nationalistic preference for either of these languages in the field of artificial intelligence. Let's take the best from both worlds for Pilog!

Still today, Prolog is the most important and popular logic programming language and used in research and education, although it is rarely seen in industrial applications. It has had significant influence on other languages such as Clojure and Erlang.

Prolog is well-suited for specific tasks that benefit from rule-based logical queries such as searching databases, voice control systems, and filling templates.

How much Prolog is needed for Pilog?

In order to understand Pilog, I went through the free online version of Learn Prolog Now! as a reference for the next posts.

The Learn Prolog Now! course is structured in 12 chapters, of which we will pick the following 7 most important ones to understand Pilog:

  • Chapter 1 Facts, Rules, and Queries
  • Chapter 2 Unification and Proof Search
  • Chapter 3 Recursion
  • Chapter 4 Lists
  • Chapter 6 More Lists
  • Chapter 10 Cuts and Negations.

Basically we will follow the content of these chapters, only that the syntax will be translated from Prolog to Pilog.

This means that the following chapters will be skipped. The main reason why we not need them is because we also have the possibility to call PicoLisp functions from within Pilog.

  • Chapter 5 Arithmetic
  • Chapter 7 Definite Clause Grammars
  • Chapter 8 More Definite Clause Grammars
  • Chapter 9 A Closer Look at Terms
  • Chapter 11 Database Manipulation and Collecting Solutions
  • Chapter 12 Working With Files

Installing Pilog and Prolog

Pilog comes with the standard pil21-distribution, there is no need for an additional installation. If you are using an older version of PicoLisp (for example from the Ubuntu repository or similar), consider to update the newest one (instructions here).

I also installed Prolog while I created the Pilog introductory posts. If you want to compare the Pilog syntax to Prolog or make some tests, I recommend to install Prolog on your system. There are two major implementations available: SWI-Prolog and SICStus Prolog, which is commercial. So unless you want to pay 165€ per year, you should choose SWI-Prolog.

On Linux systems, you can install it with the following commands:

$ sudo apt-add-repository ppa:swi-prolog/stable
$ sudo apt-get update
$ sudo apt-get install swi-prolog
Enter fullscreen mode Exit fullscreen mode

or you can get it from the GIT repository. There are also stable releases for Windows and MacOSX, and a termux-binary for Android.

In the next post, we will really start with Pilog and learn about the basic facts, rules, and queries.


Top comments (0)