-->

 

jDREW

 

 
<--

 

The jDREW FAQ

 

1.      What is the jDREW package composed of?

2.      How can I quickly write a program like the demo?

3.      What is the unit test?

4.      What is bottom-up?

5.      Which part of jDREW will use the libraries in the “lib” directory?

6.      What are the main data structures used in jDREW.

 

1. What is the jDREW package composed of?

jDREW package is composed of 5 subpackages: BU, TD, TEST, lib, util, each of which is located in a subdirectory of the same name as the package.

util” : this package contains all the fundamental classes or data structures of jDREW.

lib”: this package contains the libraries that is used by the jDREW.

TEST”: this package contains the unit test code of jDREW

BU”: this package contains the classes of a buttom-up reasoning engine built on jDREW.

TD”: this is an experiment package that contains a preliminary top-down reasoning engine built on jDREW.

2. How can I quickly write a program like the demo?

In the “BU" package, you will find a “ForwardReasoner.java” file. This file is in fact a command line version of the demo engine (yet it is not able to parse the RuleML rule set). “BU” package also includes several rule files that contain some example rules and facts. You need find out the “dcfp.parseDCFile(…);” statement and replace “…” with the “full directory name” of your input rule file. For example, if you want the “c:\example.dc” be your input rule file, the statement should look like this “dcfp.parseDCFile(“c:\\example.dc”);”. Then you can compile the whole jDREW package and run the “main” function of the “ForwardReasoner”.

3. What is the unit test?

Unit test is used by the jDREW developers to insure the quality of the code. For more information, please visit http://junit.sourceforge.net/.

4. What is bottom-up?

Also called forward chaining. They both describe the kind of inference process which first gathers some information and then tries to infer from it whatever can be inferred.

5. Which part of jDREW will use the libraries in the “lib” directory?

The three libraries in the “lib” directory are used for the unit test (junit.jar) and the RuleML (XML) file parser (jdom.jar, xerces.jar). All the unit test code appears in the “TEST” package. There are two java files that will use jdom.jar and xerces.jar. one is RuleMLFileParser.java that uses the libraries to parse the RuleML file. The other is DefiniteClause.java that uses the libraries to generate the RuleML output of a definite clause.

6. What are the main data structures used in jDREW?

There are three important data structures of jDREW.

  1. SymbolTable: a symbol table is an array of print names and arities of symbols. For instance in p(f(g­1), h, h(g2)), p has arity 3, f has 1, 1, g2  has arity 0. There are two different symbols h, with arity 0 and with arity 1. The symbol table for this atom will appears as follows:

 

name

arity

1

p

3

2

f

1

3

g1

0

4

g2

0

5

h

0

6

h

1

 

  1. DefiniteClause: DefiniteClause is a Java class that is used to internally represent atoms and clauses. DefiniteClause uses flatterms [1] to represent altoms and clauses. A flatterm is a pair of arrays of short integers: symbol and length. Each predicate symbol, function symbol and variable in the formular has a position in these arrays. The first array of the flatterm, symbol, contains the symbol table index for predicate or function symbol in this position. The second array, length, contains the length of the subformular beginning at this position. In jDREW, the scope of a variable only covers a clause and no further. The variables in each clause are numbered with negative indices starting at –1, and there is no confusion with variables from other clauses. The following two flatterms represents p(f(g­1), h, h(g2)) and p(f(h(X)), h(Y), f(X), Y) using the above symbol table.

 

symbol

length

 

 

symbol

length

1

1

7

1

1

9

2

2

2

2

2

3

3

3

1

3

6

2

4

5

1

4

-1

1

5

6

2

5

6

2

6

4

1

6

-2

1

7

3

1

7

2

2

 

8

-1

1

       p(f(g­1), h, h(g2))

9

-2

1

 

P(f(h(X)), h(Y), f(X), Y)

 

                                                                                                      

  1. DiscTree: DiscTree implements the discrimination tree [2] data structure. The discrimination tree is used in jDREW to find atoms that are likely to unify with a given goal atom. The flatterm of each definite clause are organized in the DiscTree according to its index atom. The following figure shows the a fragment of the discrimination tree for two clauses whose index atoms are p(f(g­1), h, h(g2)) and p(f(h(X)), h(Y), f(X), Y). Each internal node of the discrimination tree contains a function or predicate symbol that occurs somewhere in the index atom. All variables are replaced by * and are treated as the same symbol. If two atoms have the same symbols in positions 1 to n, but a different symbol in position n+1 then the node corresponding to the first n positions will have (at least) two children. At each leaf of the discrimination tree we store the clause whose index atom corresponds to the path from the root.

                     

 

 

 

 

Contacts

Site Contact: Bruce Spencer.  Last updated: 2004-1-05

jDREW is an open source project under the GNU General Oublic License (GPL). For more information, please visit http://sourceforge.net/projects/jdrew/.