Class KnowledgeBase

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--KnowledgeBase

public class KnowledgeBase
extends java.util.Hashtable

Each Conjunction has a KnowledgeBase. When an AND is beneath an OR, a clone of the KB at the OR is created so that values can differ on different ORed paths.

See Also:
Serialized Form

Field Summary
(package private) static java.util.HashSet classesNotFound
           
(package private) static boolean DEBUG
           
(package private) static java.lang.String em
           
(package private) static java.lang.String loc
           
(package private)  java.lang.String name
           
(package private)  UnificationTable uT
           
(package private) static java.lang.String wm
           
 
Fields inherited from class java.util.Hashtable
count, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, serialVersionUID, table, threshold, values, VALUES
 
Constructor Summary
KnowledgeBase()
           
KnowledgeBase(int i)
           
KnowledgeBase(java.lang.String n)
           
 
Method Summary
 void clearSubstitutions()
          Clears the substitutions that have been proposed to the UnificationTable.
 java.lang.Object clone()
           
 Predicate getMoreSpecificPredicateOrNull(Predicate p1)
          Check uT for values of variables in the predicate, and instantiate vars to the extent possible.
 java.util.Vector getVariableBindings(Variable var)
          Return the bindings from the UnificationTable.
private static boolean isVariableName(java.lang.String s)
           
static void main(java.lang.String[] args)
           
static Predicate makePredicate(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)
           
static Predicate readPredicate(java.lang.String arg)
          When you create a Predicate, if the name of the predicate corresponds to the name of a java class, the constructor of that class will be called automatically.
static Predicate readPredicate(java.lang.String arg, java.util.Hashtable varNames)
           
static java.util.Vector readPredicateList(java.io.StreamTokenizer sT)
           
static java.util.Vector readPredicateList(java.lang.String arg)
           
static java.util.Vector readPredicateTree(java.io.StreamTokenizer sT)
           
static java.util.Vector readPredicateTree(java.lang.String arg)
           
 void store(Predicate p)
           
 java.lang.String toString()
           
 boolean unifiablePredicates(Predicate p1, Predicate p2)
          Return true if two predicates have been found unifiable in the Kb and UnificationTable.
 boolean unifyPredicateInList(Predicate p1, java.util.Enumeration e1)
          Returns true if method can unify Predicate with 1 to n Predicates from Enumeration.
 boolean unifyPredicates(Predicate p1, Predicate p2)
          Return true if two predicates have been found unifiable and their variables are now unified in the KnowledgeBase.
 
Methods inherited from class java.util.Hashtable
clear, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, values, writeObject
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

uT

UnificationTable uT

name

java.lang.String name

classesNotFound

static java.util.HashSet classesNotFound

em

static java.lang.String em

wm

static java.lang.String wm

loc

static java.lang.String loc

DEBUG

static boolean DEBUG
Constructor Detail

KnowledgeBase

public KnowledgeBase()

KnowledgeBase

public KnowledgeBase(int i)

KnowledgeBase

public KnowledgeBase(java.lang.String n)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.util.Hashtable

getMoreSpecificPredicateOrNull

public Predicate getMoreSpecificPredicateOrNull(Predicate p1)
Check uT for values of variables in the predicate, and instantiate vars to the extent possible. If fully specified, then store in kB. If not fully specified, try to find a more specific predicate in kB. If not there return null.

isVariableName

private static boolean isVariableName(java.lang.String s)

makePredicate

public static Predicate makePredicate(java.lang.Object o1,
                                      java.lang.Object o2,
                                      java.lang.Object o3)

readPredicate

public static Predicate readPredicate(java.lang.String arg)
When you create a Predicate, if the name of the predicate corresponds to the name of a java class, the constructor of that class will be called automatically. For example, readPredicate( "(EPS IBM ?y)" ) creates an object of class "EPS", a subclass of predicate. Names that do not correspond to class names will print a warning and be instantiated as general Predicate objects. Hashtable varNames allows use of same variable for each string

readPredicate

public static Predicate readPredicate(java.lang.String arg,
                                      java.util.Hashtable varNames)

readPredicateTree

public static java.util.Vector readPredicateTree(java.io.StreamTokenizer sT)

readPredicateTree

public static java.util.Vector readPredicateTree(java.lang.String arg)

readPredicateList

public static java.util.Vector readPredicateList(java.io.StreamTokenizer sT)

readPredicateList

public static java.util.Vector readPredicateList(java.lang.String arg)

store

public void store(Predicate p)

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Hashtable

unifiablePredicates

public boolean unifiablePredicates(Predicate p1,
                                   Predicate p2)
Return true if two predicates have been found unifiable in the Kb and UnificationTable. Does not make unification permanent in kB, only says if it is possible. A series of calls to this method all must be unifiable until substitutions are made by unifyPredicates or clearSubstitutions() is called. make recursive? Expects p2 to be more general than p1.

clearSubstitutions

public void clearSubstitutions()
Clears the substitutions that have been proposed to the UnificationTable.
See Also:
#UnificationTable.clearSubstitutions()

unifyPredicateInList

public boolean unifyPredicateInList(Predicate p1,
                                    java.util.Enumeration e1)
Returns true if method can unify Predicate with 1 to n Predicates from Enumeration. Expects Predicates in Enumeration to be at least as general. Modifies KnowledgeBase if successful by calling unifyPredicates().

unifyPredicates

public boolean unifyPredicates(Predicate p1,
                               Predicate p2)
Return true if two predicates have been found unifiable and their variables are now unified in the KnowledgeBase. Expects second argument to be at least as general as first. Handles non-simple Predicates (KNOW, ACHIEVE) by unifying their Predicate arguments. Recursive calls on Predicate args unify all prior substitutions if recusion reaches the bottom and returns true.

getVariableBindings

public java.util.Vector getVariableBindings(Variable var)
Return the bindings from the UnificationTable. Can be other Variables and up to one constant.

main

public static void main(java.lang.String[] args)