Using ECLiPSe Prolog 6 in labs. * How do I start ECLiPSe Prolog in the labs? Windows: go to Start menu -> All Folders -> ECLiPSe6.0 -> TkEclipse You can also run O:\Program Files\ECLiPSEe 6.0\tkeclipse.bat Linux: o Reboot the machine into Linux (or if you are in Windows and don't want to reboot, start the program called XMing). If using Windows and XMing, you have to configure your SSH connection to enable forwarding of X11 window output. E.g., in PuTTY: Connection->SSH->X11->Enable X11 forwarding: yes, X display location: ":0.0" If you don't do this, you get a missing display error. (all this, of course, is if you're using the Prolog GUI) Similarly, if you connect from linux enable X with "ssh -X" flag. o Log into any moon computer. o Start an X terminal. o In the X-Terminal window, type "tkECLiPSe &" (notice mix of capital and lower-case letters) or the longer command /opt/ECLiPSe/bin/x86_64_linux/tkeclipse & This will start Prolog with a convenient GUI. If you would like to use a command-line ECLiPSe Prolog, run "ECLiPSe &" (notice the upper-case and lower-case letters) or /opt/ECLiPSe/bin/x86_64_linux/eclipse Note that you cannot simply type "eclipse" because this command may start an "eclipse IDE" that is not related to Prolog To exit from the command-line Prolog, type halt, period (+Enter). * How do I compile (load) my program in ECLiPSe Prolog? o On main menu, click on File -> Compile. o Select "All files (*)" from the "File of type" drop box to show all files of all extensions (choose filename.pl) o Locate and double click on your program to load it. Optionally, you might wish to do the following (to avoid repeating the second step above every time you compile your program, if all your Prolog programs have the default extension ".ecl" or extension ".pl"): o Click on Tools-> TkEclipse Preference Editor. o In the box labeled "Default extension for file browser", enter the string ".ecl" (the string ".pl", respectively). o Click "Apply Preferences" and then "Save Preferences" and then "Close". * How do I recompile my program after I modified its source file? o Click on File-> Clear top-level module. o Click OK o Compile you program as described in the question above. Note: Clicking on the "Make" button will, in theory, also recompile your program. This method is convenient, but it does not work properly every time, however. * What should I do if Prolog gives me a warning message about a "singleton variable"? o Ignore: this is not an error message. * How do I type ; if I want to get more answer in ECLiPSe Prolog? You can't. Click the "more" button instead. It is next to the "run" button. However, you can request more answers by typing ; in the command-line version, if for some reason you do not want using the GUI version. * How do I make the fonts in ECLiPSe Prolog more readable? o Click on Tools -> TkEclipse Preference Editor. o Change the values in first 4 text boxes (eg, courier | 16 | helvetica | 12) o Click "Apply Preferences". o Click "Save Preferences". o Click "Close". * How I can trace (debug) my program? o Click on Tools -> Tracer. This will open the new window that is very convenient for debugging purposes o Type (or Copy/Paste) your query in Query Entry field (as usual) o Click on "run" o In the Tracer window choose whether you would like to Creep (follow every step), or Skip (evaluate the predicate in the head of a rule without looking into the details of what predicates will be called), or Leap (execute without interruptions). The debugger/tracer will follow through your program, so that you can interrupt execution of your program as soon as you found a bug, edit your program, recompile and start again. Later in the course you will need this information. * What if ECLiPSe Prolog complains that my clauses are not consecutive for one of my predicates, say myPred(X,Y) ? o Write at the top of your program :- discontiguous(myPred/2). for each of your predicates whose clauses (atomic statements and rules) are not consecutive. The number after "/" is the number of arguments in your predicate. You can run the query help(discontiguous). in the Query Entry field if you would like to know more about this compiler instruction. Alternatively, if rules and atomic statements are not consecutive, or split over several files, you can write at the top of your program the following declaration: :- dynamic myPred/2, anotherPred/1. to say that both the 2-argument predicate myPred and the 1-argument predicate anotherPred will appear non-consecutively. The first approach is preferable for simple programs that are written in a single file. Once you have added the correct "discontiguous" declarations, the Error message "procedure clauses are not consecutive" should disappear after re-compilation. * What if ECLiPSe Prolog complains that I'm trying to redefine a system predicate, e.g., the predicate member(X,L), append(L1,L2,L3), date(X), etc. There are several ways to solve this problem. Below are some alternative solutions. o Rename your "predicate" to something that is different from a system predicate, e.g., predicate2, predicateNew, my_predicate, etc. This is the most portable and easiest solution. Example: instead of member(X,L) you can use the following names is_member(X,L) or member2(X,L) or memberOf(X,L) etc. o Put comments on all your rules that define that predicate. However, you might need them if you work with another implementation of Prolog (but you do not need them if you work exclusively with ECLiPSe Prolog). For this reason, this solution is less portable.