To implement Prolog we need to start with some basic items. First, all constants are represented by Strings. Variables are represented by instances of the class Var. Each variable has a name and a binding: public class Var { String name; Object binding; } The value of binding is the value the variable is bound to. It may be a constant or another variable. If the binding field is set to null, then the variable is considered unbound. Next, we need something to represent terms like inside(baltimore, maryland). This kind of term is called a structure. Structures are implemented as instances of the class Structure: public class Structure { public Object predicate; public Object arg[]; } |