org.aspic.inference
Class Constant

java.lang.Object
  extended by org.aspic.inference.Element
      extended by org.aspic.inference.Constant
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ConstantNumber, Term

public class Constant
extends Element
implements java.lang.Cloneable

A Constant is the simplest sub-class of Element. It encapsulates a functor that can be used to represent a prolog grounded atom.

Author:
mjs (matthew.south @ cancer.org.uk)
See Also:
Serialized Form

Constructor Summary
Constant()
          Default Constructor.
Constant(java.lang.String functor)
          Typical constructor.
 
Method Summary
 Constant apply(Substitution subs)
          Return copy of this Element with the substitution applied.
 java.lang.Object clone()
          An element is incompletely cloned.
 boolean equals(java.lang.Object o)
           
 java.lang.String getFunctor()
          Simple getter for functor.
 int hashCode()
           
 java.lang.String inspect()
          (idea from the Ruby prototype) inspect allows us to see a representation of the text expression that the object is based on.
 boolean isEqualModuloVariables(Element testClause)
          Check to see if this Element matches another, bar Variable names i.e.
 boolean isGrounded()
          Check for free variables
 boolean isUnifiable(Element toUnify)
          Return true if this Element can be unified with the passed Element.
 Constant negation()
          Get's the negation of this constant, a Term with functor "~", and parameters (functor).
 java.lang.String ruleTag()
          Used as the key in KnowledgeBase.rulesMap.
 void setFunctor(java.lang.String functor)
          Simple setter of functor.
 Substitution unify(Element toUnify, Substitution subs)
          Try to unify this Element with another Element, using passed substitution as a starting point.
 void write(KnowledgeWriter writer)
          Using the Visitor pattern, this method allows the details of an Element to be written in different ways.
 
Methods inherited from class org.aspic.inference.Element
getId, getKnowledgeBase, setId, setKnowledgeBase, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constant

public Constant()
Default Constructor.


Constant

public Constant(java.lang.String functor)
Typical constructor. A Constant needs a functor.

Parameters:
functor -
Method Detail

getFunctor

public java.lang.String getFunctor()
Simple getter for functor.

Returns:
constant's functor.

setFunctor

public void setFunctor(java.lang.String functor)
Simple setter of functor.

Parameters:
functor - new functor.

negation

public Constant negation()
Get's the negation of this constant, a Term with functor "~", and parameters (functor).

Returns:
Term representing negation of this Constant

inspect

public java.lang.String inspect()
Description copied from class: Element
(idea from the Ruby prototype) inspect allows us to see a representation of the text expression that the object is based on. Not implemented by overriding toString() because it's still useful to be able to inspect the objectID which toString returns.

Specified by:
inspect in class Element
Returns:
String representation of this knowledge atom

apply

public Constant apply(Substitution subs)
Description copied from class: Element
Return copy of this Element with the substitution applied.

Specified by:
apply in class Element
Parameters:
subs - Substitution to apply
Returns:
Copy of this Element with substitution applied to it.

isUnifiable

public boolean isUnifiable(Element toUnify)
Description copied from class: Element
Return true if this Element can be unified with the passed Element.

Specified by:
isUnifiable in class Element
Returns:
true iff testClause can be unified with the passed clause

unify

public Substitution unify(Element toUnify,
                          Substitution subs)
Description copied from class: Element
Try to unify this Element with another Element, using passed substitution as a starting point. If the clause is not unifiable (@see isUnifiable), subs is returned unaffected.

Specified by:
unify in class Element
Parameters:
toUnify - Element to be unified with this Element
subs - starting substitution
Returns:
Most General Unifier (MGU) as a Substitution object

isEqualModuloVariables

public boolean isEqualModuloVariables(Element testClause)
Description copied from class: Element
Check to see if this Element matches another, bar Variable names i.e. likes(john, X) isEqualModuloVariables to likes(john, Y).

Parameters:
testClause - Element to checked against this one.
Returns:
true iff testClause is the same as this Element, apart from Variable names.

isGrounded

public boolean isGrounded()
Description copied from class: Element
Check for free variables

Returns:
true iff this Element has no free variables

ruleTag

public java.lang.String ruleTag()
Used as the key in KnowledgeBase.rulesMap.

Returns:
a string that identifies this constant (or term).

write

public void write(KnowledgeWriter writer)
Description copied from class: Element
Using the Visitor pattern, this method allows the details of an Element to be written in different ways.

Specified by:
write in class Element
Parameters:
writer - the object that does the writing.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from class: Element
An element is incompletely cloned. Everything except it's knowledgeBase reference is cloned.

Overrides:
clone in class Element
Throws:
java.lang.CloneNotSupportedException