Learning Pilog - 1: A Short Introduction to Prolog

Search for a command to run...

No comments yet. Be the first to comment.
In this series, we will introduce Pilog, a declarative language which is built on top of PicoLisp. It has the semantics of Prolog, but uses the syntax of Lisp.
This post follows the tutorial from "Learn Prolog Now!", Chapter 1. The goal of this post is to introduce the basic concept and syntax of Pilog and to write some first small programs. The Knowledge Base In imperative programming, the programmer lite...
In our previous post, we introduced how to utilize Discrete Event Simulation (DES) in PicoLisp. Now, let's explore another application: a railroad model simulation that includes tracks and trains. The visualization is ASCII-based, so feel free to unl...

The Dining Philosophers

In this post, we will introduce the concept of co-routines and how they are handled in PicoLisp. This will be the foundation for the subsequent posts on Discrete Event Simulation and finally a couple of examples, including an ASCII model railway simu...

One of the many nice things of PicoLisp is that it comes with a built-in database. This makes it easy to collect and store our own data, for example via a mobile app. But not all data is best represented in tables and lists: sometimes a colorful litt...

In the last two posts, we have built a little app that shows the current location and displays the nearest ice cream shops: https://picolisp-explored.com/an-openstreetmap-app-written-in-picolisp-pt-1 https://picolisp-explored.com/an-openstreetmap-ap...

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.
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.
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:
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.
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
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.
http://www.let.rug.nl/bos/lpn//lpnpage.php?pageid=online
https://dev.to/donaldkellett/less-than-12-days-of-prolog---a-guide--brief-review-of-the-prolog-programming-language-1dgl