Lession 1
Lession 2
Lession 3
Lession 4
Lession 5
Lession 6
Lession 7
Lession 8
Lession 9
Lession 10
Lession 11
Lession 12
Lession 13
Lession 14
Lession 15
Lession 16
Lession 17
Lession 18
Lession 19

Home | Text version
Download swi-prolog | Download these scripts

Learn Definite Clause Grammars (DCG) with Toki Pona


With the Definite Clause Grammars (DCG) is it possible to describe a language. But this is not a simple thing because natural languages are not simple. DCG programs represent mostly only parts of a human language. My aim is to describe a complete language. This language has to be very simple because I am not a genius. For example Esperanto is not simple enough (for me ;-). I hope Toki Pona is simple enough for my aim. I write Prolog scripts to describe the grammar rules of every of Toki Pona lessons of my website.

DCG notation is syntactic sugar for normal definite clauses of Prolog. Prolog is an old programming language for artificial intelligence. Prolog is different to the most programming languages. You don't have to program the solution for a problem. You describe the situation and Prolog tries to find the solution. For Prolog it's better if you have not experiences in other programming languages. ;-)

Not every implementation of Prolog support DCG. I use the free SWI-Prolog. First you have to install swi-prolog.

For edit the source code you can use the atom editor with the prolog plugin. On MS Windows you can use the the swi-prolog editor also.

Download and decompress the scripts of this lessons.

Start swi-prolog in the directory where the scripts are (here in Ubuntu):

$ swipl

Now you can load a script of these lessons. For example the Prolog script for lesson one:


Please see in the lesson how to use the commands of the scripts.

You can test some of my scripts without installing SWI-Prolog. Use Chromium browser and go to Click in the left window on "Program" and copy the cource code in the left window. In the bottom right you can type your query. For example the query to list all possible sentences with this grammar:

?- sentence(X,[]).

The button "Next" show the next possibility. This is the same as ";" in installed prolog.

The Prolog script of the first lesson in the browser.


To Learn Prolog

To Learn DCG



Download swi-prolog | Download these scripts | My langugage Projects on Github | contact | Berlin (Good Old Europe)
This unofficial fan site by Robert Warnke is based on the official Toki Pona book and website: