|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnars.language.Term
nars.language.Variable
public class Variable
A variable term, which does not correspond to a concept
Nested Class Summary | |
---|---|
static class |
Variable.VarType
Four variable types plus a wild card |
Field Summary | |
---|---|
private CompoundTerm |
scope
The minimum CompoundTerm what contains all occurences of this variable |
private Variable.VarType |
type
Type of the variable |
Fields inherited from class nars.language.Term |
---|
name |
Constructor Summary | |
---|---|
|
Variable(java.lang.String s)
Constructor, from a given variable name |
private |
Variable(java.lang.String n,
Variable.VarType t,
CompoundTerm s)
Constructor, with all fields |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clone a Variable |
boolean |
equals(java.lang.Object that)
Whether this variable equals another one |
static java.util.HashMap<java.lang.String,Term> |
findSubstitute(Variable.VarType type,
Term term1,
Term term2)
To find a substitution that can unify two Terms without changing them |
private static java.util.HashMap<java.lang.String,Term> |
findSubstitute(Variable.VarType type,
Term term1,
Term term2,
java.util.HashMap<java.lang.String,Term> subs)
To recursively find a substitution that can unify two Terms without changing them |
private static java.util.HashMap<java.lang.String,Term> |
findSubstituteVar(Variable.VarType type,
Variable var,
Term term,
java.util.HashMap<java.lang.String,Term> subs,
boolean first)
To find a substitution that can unify a Vriable and a Term |
java.lang.String |
getConstantName()
Variable name is omitted in sorting |
java.lang.String |
getName()
Get variable name with dependency list (if any) |
java.lang.String |
getStoredName()
Get variable name without dependency list (if any) |
Variable.VarType |
getType()
Get the type of the variable |
java.lang.String |
getVarName(boolean first)
Rename a variable temporally to distinguish it from variables in other Terms |
int |
hashCode()
Get a hash code for the variable |
boolean |
isConstant()
A variable is constant |
static boolean |
match(Variable.VarType type1,
Variable.VarType type2)
Whether two variable types can match each other in unification |
void |
setName(java.lang.String n)
Rename the variable |
void |
setScope(CompoundTerm t)
Set the scope of the variable |
static boolean |
unify(Variable.VarType type,
Term t1,
Term t2,
Term compound1,
Term compound2)
To unify two Terms, then apply the substitution to the two compounds |
Methods inherited from class nars.language.Term |
---|
compareTo, getComplexity, getOrder, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Variable.VarType type
private CompoundTerm scope
Constructor Detail |
---|
public Variable(java.lang.String s)
s
- A String read from inputprivate Variable(java.lang.String n, Variable.VarType t, CompoundTerm s)
n
- Variable names
- Variable scopet
- Variable typeMethod Detail |
---|
public java.lang.Object clone()
clone
in class Term
public java.lang.String getConstantName()
getConstantName
in class Term
public java.lang.String getVarName(boolean first)
first
- Whether it is the first term
public void setName(java.lang.String n)
n
- The new namepublic Variable.VarType getType()
public void setScope(CompoundTerm t)
t
- The new scopepublic boolean equals(java.lang.Object that)
equals
in class Term
that
- The other variable
public int hashCode()
hashCode
in class Term
public java.lang.String getStoredName()
public java.lang.String getName()
getName
in class Term
public boolean isConstant()
isConstant
in class Term
public static boolean match(Variable.VarType type1, Variable.VarType type2)
type1
- Type of the first variabletype2
- Type of the second variable
public static boolean unify(Variable.VarType type, Term t1, Term t2, Term compound1, Term compound2)
type
- The type of Variable to be unifiedt1
- The first Term to be unifiedt2
- The second Term to be unifiedcompound1
- The first compound to be substitutedcompound2
- The second compound to be substituted
public static java.util.HashMap<java.lang.String,Term> findSubstitute(Variable.VarType type, Term term1, Term term2)
type
- The type of Variable to be substitutedterm1
- The first Term to be unifiedterm2
- The second Term to be unified
private static java.util.HashMap<java.lang.String,Term> findSubstitute(Variable.VarType type, Term term1, Term term2, java.util.HashMap<java.lang.String,Term> subs)
type
- The type of Variable to be substitutedterm1
- The first Term to be unifiedterm2
- The second Term to be unifiedsubs
- The substitution formed so far
private static java.util.HashMap<java.lang.String,Term> findSubstituteVar(Variable.VarType type, Variable var, Term term, java.util.HashMap<java.lang.String,Term> subs, boolean first)
type
- The type of Variable to be substitutedvar
- The Variable to be unifiedterm
- The Term to be unifiedsubs
- The substitution formed so farfirst
- If it is the first Term in unify
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |