CS 6795 Semantic Web Techniques

Lab 5


Prolog and POSL examples running in jDREW and OO jDREW

If you are interested in the Prolog examples running in a Java implementation, use the original jDREW as described below.

If you are interested in an extended (GUI-based) functionality, start the newer OO jDREW from http://www.jdrew.org/oojdrew/demo.html or download its Java implementation from http://www.jdrew.org/oojdrew/download.html,
and use POSL versions of the examples (POSL variables are “?”-prefixed).

1.     This lab assumes you have installed Java on your computer. There are several options to achieve this as there are a number of other IDE’s available. The most popular now, while rather large, is Eclipse http://www.eclipse.org/downloads/. Another popular alternative is the tiny Emacs-based JDEE http://jdee.sunsite.dk/ and see http://www.ibm.com/developerworks/java/library/j-emacs/ . See http://www.cs.unb.ca/courses/gen for some instructions from FCS for an older installation of JDEE that still appears to work well. Any FCS lab computer probably has Java installed. You may use any Java environment with which you are already familiar. 

2.     Create a new project directory and populate it with the contents of this zip file: j-DREW.zip.  Note that this jDREW version is a simplified version – no purpose or warranty is stated or implied. Compile the file PrologTopLevel.java.  Depending on your system this means invoking something like javac PrologTopLevel.java  which should invoke java’s compiler on all Java files in the directory. Note that you may need to explicitly refer to jar files on the classpath, so try
javac -classpath .;jdom.jar;xerces.jar PrologTopLevel.java. 

3.     Try running the class PrologTopLevel (something like java PrologTopLevel, perhaps needing the jar files on the classpath). Note that one of the lines in the PrologTopLevel.java file is  dt.parseDCFile("examples.dc"); This means that the file examples.dc, which contains the examples discussed in class during the Prolog Tutorial, will be read into the discrimination tree data structure. To find out who is holding a party, your interaction should look something like this, where your input is in red:
Enter a query
more? (y/n) [y] y
No (more) answers

4.     Answer these questions – you may need to be creative in your use of j-DREW, and may need to recompile various parts.

1.     Prolog assumes the order of clauses is important.  Does j-DREW?

2.     Does j-DREW assume that the order of goals in a clause is important?  How can you tell?

3.     Recompile PrologTopLevel.java with SHOW_TREE set to TRUE.  What effect does that have?  Try out the on_route example with the query on_route(Where).

4.     Change the on_route example so that the second clause reads

Since “,” means “and” and since A and B is the same as B and A, it should have no effect, right? Check it out with the query

5.     Change the dfsolver from a depthFirstSolutionIterator to an iterativeDepthFirstSolutionIterator.  What effect does that have on the modified on_route example using the same query?  Revert the literals in the second clause back to their original order.  What is the order of solutions now?  What criteria does the iterativeDepthFirstSolutionIterator use to order its solutions?

6.     Look into the DCTree.java and find the INTERNAL_TRACE variable, and set it to TRUE.  Recompile and run a small query and also the on_route(Where) query. Can you make sense of some of the voluminous information?  It is probably easier to make sense of the output from the depthFirstIterator than it is from the iterativeDepthFirstIterator.



Maintained by Harold Boley