Prolog
Created by French researchers in 1972. Prolog represents yet another major programming paradigm, logic programming. In this paradigm, programs are expressed as facts and rules, and a program is essentially a proof of a stated goal, using first-order predicate logic. This is a declarative language that lends itself to simple yet brilliant programs for many tasks, shifting most of the work from the programmer to the compiler or interpreter.
Useful Links
- Roman Barták's Guide to Prolog Programming is a decent and pretty fast introduction to the most important features of the language.
- GNU Prolog is the compiler we will be using. Check here for a complete and detailed manual.
- You also might like the "Quick-n-Dirty" tutorial.
- Wikipedia page
- 99 bottles of beer program.
Tools
We will use the GNU prolog interpreter and compiler version 1.4.5.
Everything you need is already installed on CS department lab machines.
To install on your virtual machine, follow these steps:
-
Run
sudo apt install -y gprolog gprolog-doc
- That's it!
How I will run your code
You should probably use the interactive program
gprolog
in development. However, for testing your code,
I will use the GNU Prolog compiler program gplc
, as
described below. In order for this to work, you must declare
an initial goal, with a line of the form
:- initialization(INITIAL_GOAL_HERE).
For example, in the 99 bottles program linked above, this line would be
:- initialization(drink(beer,99)).
(Of course, the trailing period is crucially important.)
The programs you submit should be in a single file
called proj.EXTENSION
, for either part of the project.
I will test your code by running the following commands
using the software available in the lab environment or using the instructions
above:
gplc --no-top-level proj.pl ./proj
Phase 1 Requirements
For this language, you need to implement modifications B, D, and G. See the Phase 1 page for details on what this means.
Phase 2
See the Phase 2 Page for the list of suggested
problems. Of the ones listed, I recommend the following as being most
well-suited for Prolog:
- Make
- Game Scheduler
- Frequency count
- Find the missing digits
- ??? (you choose!)