public class Variable extends Object implements Unifiable
Unifiable
. The class
has a static attribute to differentiate variables of the same names.Modifier and Type | Field and Description |
---|---|
private int |
id |
private static int |
nextId |
private String |
printName |
Constructor and Description |
---|
Variable()
Constructor of the class.
|
Variable(String printName)
Constructor of the class.
|
Variable(Variable v)
Constructor of the class.
|
Modifier and Type | Method and Description |
---|---|
String |
getName()
Gets the name of the variable.
|
PCExpression |
replaceVariables(SubstitutionSet s)
Replaces all the variables in the variable according to the specified
bindings.
|
Variable |
standardizeVariablesApart(Hashtable<Variable,Variable> newVars)
Standardizes the variables in order to be sure that there won't be any
variable clashes.
|
String |
toString()
Returns the variable under the form of:
"variableName_id".
|
SubstitutionSet |
unify(Unifiable expr,
SubstitutionSet s)
Unifies the variable with the specified
expr expression
given the bindings s . |
private String printName
private static int nextId
private int id
public Variable()
public Variable(String printName)
printName
- the name of the variable.public Variable(Variable v)
v
- the variable object to copy and to create a new variable.public String getName()
getName
in interface Unifiable
null
if there is
no one.Unifiable.getName()
public PCExpression replaceVariables(SubstitutionSet s)
This method is recursive over all PCExpression
implementations.
This is a terminal case.
replaceVariables
in interface PCExpression
s
- the SubstitutionSet
that contains the bindings of the
variables so far.PCExpression
object representing the clause to which
the variable is bound.PCExpression.replaceVariables(model.SubstitutionSet)
public Variable standardizeVariablesApart(Hashtable<Variable,Variable> newVars)
This method is recursive over all PCExpression
implementations.
This is a terminal case.
standardizeVariablesApart
in interface PCExpression
newVars
- is a parameter to save over the recursion all the variable
replacements done so far.Variable
object representing the standardized variable.PCExpression.standardizeVariablesApart(java.util.Hashtable)
public SubstitutionSet unify(Unifiable expr, SubstitutionSet s)
expr
expression
given the bindings s
. This tries to get or add bindings in order
to make logically equivalent the variable and the specified
expression.
This method is recursive over all Unifiable
implementations.
unify
in interface Unifiable
expr
- an expression to unify with the variable.s
- the SubstitutionSet
object representing the bindings
so far and/or the constraints applied.SubstitutionSet
object that contains all the bindings
needed to unify the variable to the specified expression.Unifiable.unify(Unifiable, SubstitutionSet)
public String toString()
toString
in class Object
Object.toString()