Download presentation
Presentation is loading. Please wait.
1
An ide for teaching and learning prolog
Using Prolog Development Tools (ProDT) A good (and free) IDE for teaching and learning Prolog is ProDT, or Prolog Development Tools.
2
Installation Need Eclipse (Works on Windows, Linux, and Mac OS)
Download the plug-in from: Follow the installation and configuration instructions from the website Need a Prolog interpreter to complete the plug in configuration (SWI, B, or XSB) Check the features section for screenshots and additional help The features section of the website is a good place to start so that you can learn some shortcuts while using ProDT. When learning multiple languages, it can be hard to keep up which character or set of characters comments a line of code out. ProDT includes a key binding that let’s you do just that (Ctrl + /). Installation and configuration should be platform independent. If your machine runs Eclipse, it can run the ProDT. It is fairly easy to set up and the instructions are helpful. You must download a Prolog interpreter to complete the configuration of the ProDT plug in. These are freely available. SWI-Prolog is the default chosen by the plug in. The features section adds screenshots on how to start a project in Eclipse correctly.
3
Implementation Create new Prolog project in Eclipse
Ensure that an interpreter is selected Add a file to the project source and name it filename.pl Add source code such as: abs(X,X) :- X >= 0, !. abs(-X,Y) :- Y is X * -1. To run the file, right click and select ProDT ->Consult in Console After successful configuration, Prolog is available as a project type in Eclipse. After creation and naming the project, make sure that an interpreter is selected using the default selection or another Prolog interpreter of your choice. If there are no available selections, you need to revisit the configuration of the Prolog and make sure an interpreter has been successfully installed. Add a file and name it whatever you want with the extension .pl. Add some code to the file so that we can make sure that it works correctly. Here we are adding a simple two line function that will compute the absolute value for a given number. The console works very much like the Command Line in Windows or Linux. Up and down arrows navigate through previous commands, autocomplete is available, and you can even save the console’s output to a file.
4
Console As you can see, a console pops up at the bottom of the window allowing you to run your functions. Here we can type in abs(insert any number, Variable). and hit enter to compute the absolute value of any number given. Works perfectly. This will work for any of your functions. You can also consult more than one file in the console at a time. To end the session so that you can make changes to the code, hit the red square button.
5
Errors Errors are underlined and found automatically after saving the file Hovering the mouse over the error gives a tip on the problem Good learning tool for becoming familiar with the language and the syntax Errors in the ProDT plug in work very much like errors while using Java, for example, in Eclipse. You can easily see which line of code is causing the error. The only downside to this is that if you consult the file in the console with errors, you will still have access to the functions. They won’t work, obviously, but it would be nice to prevent the user from consulting the console when there are errors in the code.
6
Trace Trace can be used in the console to show how Prolog computes the code. Good for teaching Shows the process Prolog runs to get answers Use command: trace. Run function Progress by hitting the enter key Good for bug squashing The trace command is very useful for teaching how Prolog works. It shows the process of computation that Prolog uses for your functions. It is also good to figure out why things aren’t working as expected. All you have to do is Consult in Console with your code in Eclipse. Instead of typing in your function type trace. followed hitting enter. The console should return true. From there you type in your function as you would normally and you can trace each step. It is a form of debugging. You only have to hit enter to get to the next step. It is a very useful tool which can aid in learning, but mostly it is a good tool for teaching how Prolog works.
7
Trace in Action First function fails, second function runs and computes the correct answer. As you can see, the first function fails since it is a negative number. Prolog doesn’t know that off the bat, so it calls the function anyway. Once it gets to the condition X >= 0, it fails. So it recalls abs and goes to the second line of the function and finds that it has to compute something. It takes the number given and multiplies is by -1 and finds the correct number. It exits out of abs all the way to the top and spits out the correct answer using the variable you designated. This can get quite complex when the function is more than a few lines or when it does more than compute the absolute value. This makes in invaluable in debugging. This isn’t a feature of Eclipse, but a feature of Prolog that is easy to implement in Eclipse.
8
Conclusion Eclipse is a good solution Platform independent
Consult in Console Error Tracking Trace/Debugging Graphical User Interface Easy to use Questions? As you can see, Eclipse is a solid solution for programming in Prolog on any platform. The consult in console feature is what makes Eclipse the best. No need to always call up Prolog and always type in the file name you are using in the command line. The error tracking does what no other IDE can do for Prolog. It will save many hours and much frustration if you plan on coding in Prolog for any amount of time. The trace feature is perfect for debugging your program and shows exactly how and why Prolog came to the answer that it did with your code. The Eclipse GUI is a familiar GUI to most which makes it easy to use whether or not you are a seasoned Eclipse user or a brand new programmer.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.