CSE 230: Principles of Programming Languages
Basic Notes on Using BinProlog 4.00
These notes address some basic points to help you get started, since the online documentation for BinProlog seems to be spotty, and there are differences from what Stansifer's exposition might lead you to expect.

BinProlog 4.00 is in the directory /net/cs/class/wi99/cse230/prolog/ on the machine butinja.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. Files for some exercises may also appear in these directories, along with various other potentially useful files (but nothing is promised).

To start BinProlog, execute /net/cs/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. 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. You will find examples in the files ex1.pl and addn.html; these illustrate some useful tricks, and the latter includes some output.

You can load a file foo.pl into BinProlog by typing "consult(foo)." 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 foo.pl into BinProlog by typing "[foo]." but compilation is hardly necessary for the simple examples in this class. If you do compile, the compiler may complain about things like 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 so-called anonymous variables, denoted "_". Don't forget that relations and functors must begin with lowercase letters, and variables must begin with uppercase letters! Also, you must not put spaces before parentheses. Watch out for using names that are already taken by the system, such as append.

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". You can see what the system is doing on a query q with "trace(q)."; use a ";" to see the next step. Type "control-C" to get out of an anomalous situation, and type "halt." (or "control-D") to get out of the sytem. You can reload files with "consult" as many times as you like, but "reconsult" will undo the previously loaded definitions.

More documentation (more than you need!) can be found at art.html, and of course various places on the web - especially in Sri Lanka!

To CSE 230 homepage
Maintained by Joseph Goguen
Last modified 5 March 2002