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

BinProlog 4.00 binary for ACS Solaris machines is at prolog/bp on the class website, as well as the ACS directory for CSE 130, /home/solaris/ieng9/cs130w/public/prolog/bp where everyone in the class should have an account. It is also available in the directory /net/cs/class/wi99/cse230/prolog/ on the machine butinja.ucsd.edu, as well as in the directory /net/cat/disk1/prolog/ on the machine cat.ucsd.edu. To execute the binprolog binary, you will need a Sun workstation running Solaris or SunOS, such as the ACS machines in EBU1 and EBU2, or the CSE instructional machines beowulf, bintijua, kongo, or the machines in the APE lab. Files for some exercises also appear in these directories, possibly with some other potentially useful files (but nothing is promised).

To start BinProlog, execute the command /home/solaris/ieng9/cs130w/public/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 pl/ex1.pl and pl/addn.html; these also 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 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 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 ../230/pl/art.html, and of course various places on the web - especially in Sri Lanka!

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