|
|||||||||
Home >> All >> alice >> [ tuprolog overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
alice.tuprolog
Class Var

java.lang.Objectalice.tuprolog.Term
alice.tuprolog.Var
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class Var
- extends Term
prolog variable implementation. Variable identificators are time (a long) and a name (a string). Name is used to identify the variable from the point of view of an external user, time as internal code.
Field Summary | |
static Var |
ANY
|
(package private) Term |
link
|
(package private) int |
mark
|
java.lang.String |
name
|
(package private) int |
time
|
Fields inherited from class alice.tuprolog.Term |
FALSE, FLOAT, id, INT, NULL, OBJECT, STRUCT, TRUE, VAR |
Constructor Summary | |
|
Var()
creates an ANY variable ("_") |
|
Var(java.lang.String n)
creates a variable identified by name n |
(package private) |
Var(java.lang.String n,
int t)
|
Method Summary | |
Term |
copy(alice.util.LinkedList vl)
copying a var. |
Var |
findFromNameIn(alice.util.LinkedList vl)
finds a var Term of the list with the same Name of current Term. |
private Var |
findIn(alice.util.LinkedList vl)
finds a var Term of the list with the same time of current Term. |
private boolean |
findIn(Struct t)
finds var occurence in a Struct, doing occur-check. |
void |
free(int m)
ununification by means of the code m (only link with code greater or equal than m are free) |
java.lang.String |
getName()
significant only for Var and Struct derived class. |
Term |
getTerm()
gets the real term. |
Term |
getVar(java.lang.String name_)
significant only for Struct derived class. |
boolean |
isAny()
is it a prolog any(_) variable? |
boolean |
isAtom()
is it a prolog (alphanumeric) atom? |
boolean |
isClause()
is it a prolog clause? |
boolean |
isCompound()
is it a prolog compound term? |
boolean |
isConst()
is it a constant prolog term? |
boolean |
isEmptyList()
is it a prolog empty list? |
boolean |
isEQU(Term t)
is term equal to term t? |
boolean |
isGround()
is it a ground term? |
boolean |
isGT(Term t)
is term greater than term t? |
boolean |
isList()
is it a prolog list? |
boolean |
isNum()
is it a prolog numeric term? |
boolean |
match(Term t)
matching without unification; only true or false, without bindings. |
static int |
rename(alice.util.LinkedList vl,
int c,
boolean f)
renaming of all the variables of the argument list. |
(package private) int |
renameVars(alice.util.LinkedList vars,
int count)
|
java.lang.String |
toString()
gets string representation of the var. |
java.lang.String |
toStringFlattened()
get the flat string representation of a variable. |
boolean |
unify(Term t,
int m)
var unification. |
void |
unlink()
unlinks linked var. |
Methods inherited from class alice.tuprolog.Term |
clone, getDouble, getFloat, getInt, getIterator, getLong, getObject, getObject, getString, getStruct, getStruct, getTerm, isFalse, isFloat, isInt, isObject, isStruct, isTrue, isVar, parse, parse, parseSentence, renameVars, toRawString, toString, toStringAsArg, toStringAsArgX, toStringAsArgY |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
ANY
public static final Var ANY
name
public java.lang.String name
time
int time
link
Term link
mark
int mark
Constructor Detail |
Var
public Var(java.lang.String n) throws InvalidVarNameException
- creates a variable identified by name n
Var
public Var()
- creates an ANY variable ("_")
Var
Var(java.lang.String n, int t)
Method Detail |
getName
public java.lang.String getName()
- Description copied from class:
Term
- significant only for Var and Struct derived class.
getVar
public Term getVar(java.lang.String name_)
- Description copied from class:
Term
- significant only for Struct derived class.
getTerm
public Term getTerm()
- gets the real term.
for unbound var it's the var itself, while for bound var it's the linked term
isConst
public boolean isConst()
isNum
public boolean isNum()
isCompound
public boolean isCompound()
- Description copied from class:
Term
- is it a prolog compound term?
- Overrides:
isCompound
in classTerm
isAtom
public boolean isAtom()
- Description copied from class:
Term
- is it a prolog (alphanumeric) atom?
isClause
public boolean isClause()
isList
public boolean isList()
isEmptyList
public boolean isEmptyList()
- Description copied from class:
Term
- is it a prolog empty list?
- Overrides:
isEmptyList
in classTerm
isGround
public boolean isGround()
isAny
public boolean isAny()
findIn
private Var findIn(alice.util.LinkedList vl)
- finds a var Term of the list with the same time
of current Term.
findFromNameIn
public Var findFromNameIn(alice.util.LinkedList vl)
- finds a var Term of the list with the same Name
of current Term.
findIn
private boolean findIn(Struct t)
- finds var occurence in a Struct, doing occur-check.
renameVars
int renameVars(alice.util.LinkedList vars, int count)
- Overrides:
renameVars
in classTerm
rename
public static int rename(alice.util.LinkedList vl, int c, boolean f)
- renaming of all the variables of the argument list.
unify
public boolean unify(Term t, int m)
- var unification.
First, verify the Term eventually already unified with the same Var if the Term exist, unify var with that term, in order to handle situation as (A = p(X) , A = p(1)) which must produce X/1.
If instead the var is not already unified, then:
if the Term is a var bound to X, then try unification with X so for example if A=1, B=A then B is unified to 1 and not to A (note that it's coherent with chronological backtracking: the eventually backtracked A unification is always after backtracking of B unification.
if are the same Var, unification must succeed, but without any new bindings (to avoid cycles for extends in A = B, B = A)
if the term is a number, then it's a success and new link is created (retractable by means of a code)
if the term is a compound, then occur check test is executed: the var must not appear in the compound ( avoid X=p(X), or p(X,X)=p(Y,f(Y)) ); if occur check is ok then it's success and a new link is created (retractable by a code)
match
public boolean match(Term t)
- Description copied from class:
Term
- matching without unification; only true or false, without bindings.
free
public void free(int m)
- ununification by means of the code m
(only link with code greater or equal than m are free)
unlink
public void unlink()
- unlinks linked var.
(not used by prolog core; only for extension and not prolog manipulation )
copy
public Term copy(alice.util.LinkedList vl)
- copying a var.
if bound var then copying of the term linked, else the list passed as arg are variables already linked, so
if current var is founded in the list, then the copy of the var is the element of the list; if not, then a new copy is made and the is var added to the list
isGT
public boolean isGT(Term t)
isEQU
public boolean isEQU(Term t)
toString
public java.lang.String toString()
- gets string representation of the var.
if var bounded, then write Name/Term; else if there is no name, write underscore character
toStringFlattened
public java.lang.String toStringFlattened()
- get the flat string representation of a variable.
if var bounded, then get the string representation of the Term bound
|
|||||||||
Home >> All >> alice >> [ tuprolog overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |