JTP API Documentation

jtp
Class ReasoningStep

java.lang.Object
  |
  +--jtp.proof.Proof
        |
        +--jtp.ReasoningStep
All Implemented Interfaces:
Cloneable, Serializable, Unifyable
Direct Known Subclasses:
AskingQueryProcessor.ReformulationProofStep, Cut, DemodulationReasoningStep, DirectAssertion, EnumeratingReasoner.ProofStep, FunctionProofStep, InferredValueReasoningStep, MembershipProofStep, ModusPonensProofStep, ReasoningStepStub, RuleCreationReasoningStep, RuleInstallationProofStep, RuleTriggeringProofStep, TimePointMappingReasoningStep, TranslationReasoningStep, ValueLinkCreationReasoningStep, VCListenerCreationReasoningStep

public abstract class ReasoningStep
extends Proof
implements Unifyable, Cloneable

An extension to the InferenceWeb Proof class that specifies and implements much of the JTP-specific functionality required of proofs in JTP.

ReasoningSteps are essentially the messages that are passed between Reasoners which allow them to cooperate.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class jtp.proof.Proof
bindings, goal, inference, subGoals, subProofs
 
Constructor Summary
protected ReasoningStep()
           
  ReasoningStep(Object goal, List subSteps)
           
  ReasoningStep(Object goal, List subSteps, List subGoals)
           
 
Method Summary
protected  void addContentsIfUnifyable(Object value, Collection tgt)
           
 void backtrack()
          Unbind all variables that are keys in the bindings.
 Object clone()
          Ensures that returned clone initially has the same subgoals and subproofs as this, but they do not share lists.
protected  boolean cloneNeedsDereferencing(ReasoningStep clone)
          Determines if clone is different from this because this has data members that contain Unifyables that were dereferenced in clone.
protected  Collection collectUnifyableElements()
          Returns a collection of data members of this ReasoningStep that are instances of Unifyable.
 boolean contains(Variable v)
          Subclasses of ReasoningStep should not override this method.
protected  ReasoningStep createDereferencedClone()
          Returns a clone of this ReasoningStep in which all nested Variables have been replaced by the values that they are bound to at the time of clone creation.
protected  Map deReferenceBindings(Map bindings)
          Simplifies a bindings map.
protected  Object deReferenceElement(Object element)
          A general method for dereferencing objects that may contain Variables.
protected  List deReferenceList(List l)
          Returns a list based on l in which all elements have been dereferenced if possible with deReferenceElement(Object).
 Object deReferenceVariables()
          Subclasses of ReasoningStep should not override this method.
 float getCost()
           
 Inference getInference()
          Returns instance of AxiomInference if subproofs list is empty.
 List getSubProofs()
          Returns a List of the direct child Proofs in the proof tree.
 Collection getVariables(Collection tgt)
          Subclasses of ReasoningStep should not override this method.
 void makeStep()
          Bind Variables that are keys in bindings map to the values in the map.
abstract  String tracePrint()
          Returns a string that describes the inference that this reasoning step makes.
 boolean unify(Object param1, List param2)
          This method from the Unifyable interface should never be called on a ReasoningStep.
 
Methods inherited from class jtp.proof.Proof
getBindings, getGoal, getSubGoals, toString, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReasoningStep

protected ReasoningStep()

ReasoningStep

public ReasoningStep(Object goal,
                     List subSteps)

ReasoningStep

public ReasoningStep(Object goal,
                     List subSteps,
                     List subGoals)
Method Detail

tracePrint

public abstract String tracePrint()
Returns a string that describes the inference that this reasoning step makes.


getSubProofs

public List getSubProofs()
Description copied from class: Proof
Returns a List of the direct child Proofs in the proof tree. A proof in the subproof list at index i proves the goal in the subgoal list at index i.

Overrides:
getSubProofs in class Proof
Returns:
a list of the subproofs of this Proof
See Also:
Proof.getSubGoals()

backtrack

public void backtrack()
Unbind all variables that are keys in the bindings.

See Also:
Variable

makeStep

public void makeStep()
Bind Variables that are keys in bindings map to the values in the map.


clone

public Object clone()
Ensures that returned clone initially has the same subgoals and subproofs as this, but they do not share lists. That is, getSubGoals() and clone.getSubGoals() are equals but not ==, and the same is true for getSubProofs().

Overrides:
clone in class Object

getCost

public float getCost()

addContentsIfUnifyable

protected void addContentsIfUnifyable(Object value,
                                      Collection tgt)

deReferenceElement

protected Object deReferenceElement(Object element)
A general method for dereferencing objects that may contain Variables.

If element is a Unifyable, dereference it and return the resulting object. If element is a CNFSentence, dereference it and return the resulting sentence. Otherwise, return element itself.

Parameters:
element - an object to be dereferenced
Returns:
an object based on element in which Variables have been replaced by their bound values. If no dereferencing occurred, element is returned.

deReferenceBindings

protected Map deReferenceBindings(Map bindings)
Simplifies a bindings map. If a Variable key is bound to another Variable, the latter Variable will be the key in the returned map. If a Variable key is bound to a non-Variable object, the key-value pair will not be in the returned map. A value in the returned map will be replaced by its dereferenced self if it contains bound Variables.

Parameters:
bindings - bindings Map to be simplified. Keys are assumed to be Variables.
Returns:
a dereferenced copy of bindings. If no dereferencing occurred, bindings is returned.
Throws:
IllegalStateException - if a Variable key dereferences to a non-Variable object that is not equal to the object that its mapped value dereferences to

collectUnifyableElements

protected Collection collectUnifyableElements()
Returns a collection of data members of this ReasoningStep that are instances of Unifyable.

This default implementation handles the collection of Unifyables from the goal, bindings, subgoals, and subproofs. Subclasses should override this method if they have other data members that could contain Unifyables. Overriding methods should make a call to super to collect Unifyables from the common members mentioned above.

Returns:
a Collection of Unifyables nested in this ReasoningStep

createDereferencedClone

protected ReasoningStep createDereferencedClone()
Returns a clone of this ReasoningStep in which all nested Variables have been replaced by the values that they are bound to at the time of clone creation.

This default implementation handles dereferencing of Unifyables nested in goal, bindings, subgoals, and subproofs. Subclasses should override this method if they have other data members that could contain Unifyables that need to be dereferenced. Overriding methods should make a call to super to get initial clone that has the data members mentioned above dereferenced.

Returns:
a clone of this ReasoningStep with Variables dereferenced

cloneNeedsDereferencing

protected boolean cloneNeedsDereferencing(ReasoningStep clone)
Determines if clone is different from this because this has data members that contain Unifyables that were dereferenced in clone.

This default implementation compares goal, bindings, subgoals, and subproofs of clone and this to determine if Unifyables were dereferenced in the clone. Subclasses should override this method if they also override createDereferencedClone() and may dereference other data members in the clone. Overriding methods should make a call to super to do comparison for the data members mentioned above.

Parameters:
clone - a dereferenced clone of this created with createDereferencedClone()
Returns:
true if Unifyables were dereferenced in clone; false otherwise

contains

public boolean contains(Variable v)
Subclasses of ReasoningStep should not override this method. This method relies on the Collection returned by collectUnifyableElements() which subclasses should override if necessary.

Specified by:
contains in interface Unifyable
Parameters:
v - the variable to look for
Returns:
true if the variable was found in this Unifyable.

getVariables

public Collection getVariables(Collection tgt)
Subclasses of ReasoningStep should not override this method. This method relies on the Collection returned by collectUnifyableElements() which subclasses should override if necessary.

Specified by:
getVariables in interface Unifyable
Parameters:
tgt - the collection to which the variables are added. If null, and this Unifyable contains variables, a new collection is created.
Returns:
the target collection. If target is null, and there are no variables, null is returned; if a new collection is created, it has to be modifyable.

deReferenceVariables

public Object deReferenceVariables()
Subclasses of ReasoningStep should not override this method. This method relies on the clone returned by createDereferencedClone() and the comparison performed by cloneNeedsDereferencing(ReasoningStep). Subclasses should override these methods if necessary.

Specified by:
deReferenceVariables in interface Unifyable
Returns:
the copy of this Unifyable with all variables de-referenced. In many subclass implementations, this is returned if no variables needed to be dereferenced.
See Also:
Variable

unify

public boolean unify(Object param1,
                     List param2)
This method from the Unifyable interface should never be called on a ReasoningStep.

Specified by:
unify in interface Unifyable
Parameters:
param1 - the object to unify with.
param2 - the variable stack
Returns:
true if successful
Throws:
UnsupportedOperationException - if called

deReferenceList

protected List deReferenceList(List l)
Returns a list based on l in which all elements have been dereferenced if possible with deReferenceElement(Object).

Parameters:
l - list to be dereferenced
Returns:
dereferenced copy of l. If no elements needed dereferencing, l is returned

getInference

public Inference getInference()
Returns instance of AxiomInference if subproofs list is empty. Returns instance of ModusPonensInference if subproofs list is non-empty.

Overrides:
getInference in class Proof
Returns:
the type of inference that this Proof performs

JTP API Documentation