CSE 230: Principles of Programming Languages
Basic Notes on Using BinProlog 4.00
These notes address only some basic points to help you get started; unfortunately, the online documentation for BinProlog seems to be poor, and there are many differences from what Stansifer would lead you to expect.

BinProlog 4.00 is in the directory /cse/class/wi99/cse230/prolog/ on the machine bintijua.ucsd.edu, and as a backup also in the directory /net/cat/disk1/prolog/ on the machine cat.ucsd.edu; to execute it, you will need a Sun workstation running Solaris or SunOS, such as the CSE instructional machines beowulf, bintijua, kongo, or the machines in the APE lab. You may find files for some of the exercises on this directory (but as of this writing, no promises), along with various other files.

I suggest the following mode of work: open a file in your favorite editor, and then iteratively run that file and update it, using two windows; I prefer to do this in emacs, which allows shell buffers that can capture the output. It is nice to use the suffix .pl or .pro for Prolog files, since the system recognizes them as defaults.

To start BinProlog, execute /cse/class/wi99/cse230/prolog/bp; you may want to create an alias for this. You can discover the options with bp -x or any other illegal option, but these are not likely to be useful for this class. Watch out for using function names that are already taken by the system.

You can load the file ex1.pl into BinProlog by typing "consult(ex1)." to its prompt, which is "?-; this prompt only accepts queries, such as "kwa(yoruba).", and top level commands - all the declarations must be contained in files that are read into the system. Alternatively, you can compile the file ex1.pl into BinProlog by typing "[ex1]." - but compilation is hardly necessary for the simple examples in this class. If you do compile, the compiler will complain about the lack of a space or return at the end of the file, and also about non-tail recursive definitions; for such cases, it is desirable to use the so-called anonymous variable, denoted "_".

Don't forget that functors begin with lowercase letters and variables with uppercase letters! You will find a worked example with some useful tricks in the file /cse/class/wi99/cse230/prolog/ex1.pl.

After BinProlog has given you an answer, to get another answer just type ";" after the given answser; if you don't want any more answers, type a return instead; if there are more answers, BinProlog will say "yes" and if there are no more answers, it will say "no".

Type "control-C" to get out of an anomalous situation; type "halt." (or "control-D") to get out of the sytem. You can reload files with "consult" as many times as you like. You can see what the system is doing on a query q with "trace(q)."; use a ";" to see the next step.

More documentation (more than you need!) can be found at art.html, and of course various places on the web - especially Sri Lanka! The examples involving addition discussed in class on 23 February can be found at addn.html.

To CSE 230 homepage
Maintained by Joseph Goguen
Last modified 23 February 1999