ubc.cs.JLog.Foundation
Class jDynamicRuleDefinitions
java.lang.Object
ubc.cs.JLog.Foundation.jRuleDefinitions
ubc.cs.JLog.Foundation.jDynamicRuleDefinitions
- All Implemented Interfaces:
- iName, iNameArity
public class jDynamicRuleDefinitions
- extends jRuleDefinitions
This class represents an ordered collection of jRule
s
of the same name and arity. This is designed for dynamically defined
rules that may change during a proof. There is a performance penalty
for using dynamic rules.
- Author:
- Glendon Holst
Methods inherited from class ubc.cs.JLog.Foundation.jRuleDefinitions |
addRule, addRuleFirst, addRuleLast, clearRules, consult, enumRules, getArity, getLibrary, getName, getRuleAt, isBuiltin, match, prove, removeRule, retry, sameLibrary, setLibrary, size |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
jDynamicRuleDefinitions
protected jDynamicRuleDefinitions(java.lang.String name,
int arity,
java.util.Vector v)
- Construct dynamic rule based on name, arity, and vector of rules. For
internal duplications purposes.
- Parameters:
name
- The name for these rules.arity
- The arity for these rules.v
- The rules vector to duplicate.
jDynamicRuleDefinitions
public jDynamicRuleDefinitions(java.lang.String name,
int arity)
jDynamicRuleDefinitions
public jDynamicRuleDefinitions(jRuleDefinitions rd)
- Construct dynamic rule based on static rule definitions. Converts a
jRuleDefinition
to a dynamic rule definition.
The database should be consulted afterwards and before the next prove.
- Parameters:
rd
- The jRuleDefinitions
to duplicate. Argument
should not be used again. to ensure against this, the
dynamic rule takes total ownership of the vector
(leaving rd
empty).
createGoal
public jPredicateGoal createGoal(jCompoundTerm t)
- Overrides:
createGoal
in class jRuleDefinitions
copy
public jDynamicRuleDefinitions copy()
getClause
public jTerm getClause(jClauseGoal cg,
jPredicate h)
- Construct dynamic rule based on name, arity, and vector of rules. For
internal duplications purposes.
- Parameters:
cg
- The jClauseGoal
we are trying to prove. Contains
an index to the next clause that needs to be proved.h
- The rule head jPredicate
of the rule body. Name
and arity must match.
- Returns:
- The next
jTerm
of the rule base to prove.
null if there are no more terms.
retractUnifyRule
public boolean retractUnifyRule(jRule rule,
jUnifiedVector v)
- Attempts to retract a rule from the rule definition. Retracted rule must unify
with the provided rule. All non-retracted rules must be non-unified upon
completion.
- Parameters:
rule
- The jRule
of the type we are trying to remove.v
- The variable vector required for unification.
- Returns:
- true if the rule was retracted, false otherwise.
toString
public java.lang.String toString()
- Overrides:
toString
in class jRuleDefinitions