|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdpvis.datastructures.impl.TermImpl
public class TermImpl
Field Summary |
---|
Fields inherited from interface dpvis.datastructures.Term |
---|
NEW_VARIABLE_PREFIX |
Constructor Summary | |
---|---|
TermImpl(java.lang.String function,
java.util.List<Term> subterms,
boolean variable)
|
|
TermImpl(java.lang.String function,
java.util.List<Term> subterms,
boolean forbidden,
boolean variable)
|
|
TermImpl(Term t)
|
Method Summary | |
---|---|
void |
cap(java.lang.String var,
java.util.Collection<java.lang.String> definedFunctions)
Replaces all (not necessarily immediate) subterms of this term that are rooted by function symbol given in the second argument by a new variable. |
boolean |
containsVariable(java.lang.String var)
Computes whether the term contains the given variable. |
boolean |
containsVariablePrefix(java.lang.String prefix)
Detects whether the variables of this term contain the given variable prefix. |
void |
demarkRoot()
Removes the '#' mark from the root function of this term if it is present. |
void |
demarkVariables()
Clears the variable flags of this term (and all of its subterms). |
boolean |
equals(java.lang.Object obj)
|
void |
filter(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> filtering)
Applies an argument filtering to the term. |
java.util.Set<Term> |
getAllForbiddenSubterms(boolean include)
Computes all subterms of this term, that occur at forbidden positions (in the usual context-sensitve sense) in this term according to the forbidden flags. |
java.util.Set<Pair<java.lang.String,java.lang.Integer>> |
getAllFunctionSymbolsWithArity()
Returns all function symbols (not variables) occurring in this term and its subterms, as pair together with their arities. |
java.util.List<Term> |
getAllowedSubtermsWithRoot(java.util.List<java.lang.String> rootSymbols)
Extracts (deep) copies of all subterms, rooted by one of the given function symbols, that are allowed according to the forbidden flags. |
java.util.Set<java.lang.String> |
getForbiddenFunctions()
Returns all function symbols that occur as root of a forbidden subterm of this term. |
java.lang.String |
getFunction()
Gets the (root) function symbol (or variable) of this term. |
java.util.Set<java.lang.String> |
getFunctions()
Gets all function symbols (not variables) contained in this term and all of its subterms. |
java.util.Set<java.lang.String> |
getHiddenSymbols()
Computes the hidden symbols of a term, i.e. those function symbols (not variables) occurring as root of a non-replacing subterm of this term. |
java.util.Set<java.lang.String> |
getNonReplacingVariables()
Returns the set of variables that occur at a non-replacing position in this term according to the forbidden flags. |
java.util.List<java.lang.Integer> |
getReplacementMap(java.lang.String function)
Returns the replacment map for the specified function symbol, according to the forbidden flags of the
term and its subterms. |
java.util.Set<java.lang.String> |
getReplacingVariables()
Returns a set of variables occurring in this term at replacing positions according to the forbidden flags
of this term and its subterms. |
java.util.List<Term> |
getSubterms()
Gets the (immediate) subterms of this term. |
java.util.Set<Term> |
getSubtermsOfSignature(java.util.Set<java.lang.String> signature)
Returns deep copies of all (not necessarily immediate) subterms of this term that are rooted by a function symbol contained in the given signature. |
java.util.Set<java.lang.String> |
getVariables()
Computes all variables contained in this term (and its subterms), according to the variable flags. |
boolean |
hasConstructorContext(java.lang.String var,
java.util.List<java.lang.String> definedSymbols)
Checks whether the given variable occurs only inside constructor-contexts within this term, i.e. the root symbol if each subterm of this term containing the given variable is a constructor. |
int |
hashCode()
|
void |
instantiate(Substitution subst)
Instantiates the term with the given substitution. |
boolean |
isForbidden()
Gets the forbidden flag of this term. |
boolean |
isLinear()
Computes whether this term is linear, i.e. does not contain multiple occurrences of the same variable. |
boolean |
isNarrowable(RewriteSystem sys)
Checks whether this term or one of its allowed (according to the forbidden flags)
subterms can be narrowed according to the given Rewrite System R. |
boolean |
isProperSubterm(Term potentialSubterm)
Checks if the given term is a proper subterm of this term. |
boolean |
isSubterm(Term potentialSubterm)
Checks if the given term is a (not necessarily proper) subterm of this term. |
boolean |
isVariable()
Gets the variable flag of this term. |
void |
markForbiddenTerms(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> repMap)
Marks forbidden subterms according to the given replacement map. |
void |
markForbiddenTerms(java.lang.String function,
java.util.List<java.lang.Integer> replacementMap)
|
void |
markRoot()
Marks the root function symbol with the character '#'. |
void |
markVariables(java.util.List<java.lang.String> vars)
Marks the variables in a term, i.e. sets the variable
flags for the term and all of its subterms. |
java.util.Set<Pair<Term,Substitution>> |
narrow(RewriteSystem trs,
int variablePrefixCounter,
boolean root,
Strategy strat)
Computes all (context-sensitive) narrowings of this term and its subterms (or only of the subterms if the root parameter is false) according to the given Rewrite System. the given strategy is used set the forbidden flags of resulting terms. |
void |
removeContextSensitivityFlags()
Removes all forbidden flags from the rules of this Term. |
void |
ren(java.lang.String var)
Linearizes the term, i.e. each variable of this term (and its subterms) is replaced by a new variable, in such a way that after the replacement the term is linear. |
void |
renameVariables()
Renames all variables in the term by prefixing them with "_". |
void |
replaceVariable(java.lang.String oldVar,
java.lang.String newVar)
Replaces each occurrence of the variable oldVar by newVar. |
void |
setForbidden(boolean forbidden)
Sets the forbidden flag of this term. |
void |
setFunction(java.lang.String function)
Sets the (root) function symbol (or variable) of this term. |
void |
setSubterms(java.util.List<Term> subterms)
Sets the (immediate) subterms of this term. |
void |
setVariable(boolean variable)
Sets the variable flag of this term. |
void |
substituteAt(java.util.List<java.lang.Integer> pos,
Term substitute)
Substitutes the given substitute term for the subterm of this term at the specified position. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TermImpl(Term t)
public TermImpl(java.lang.String function, java.util.List<Term> subterms, boolean forbidden, boolean variable)
public TermImpl(java.lang.String function, java.util.List<Term> subterms, boolean variable)
Method Detail |
---|
public void markForbiddenTerms(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> repMap)
Term
markForbiddenTerms
in interface Term
repMap
- The replacement map specifying the replacement restrictions.public void markForbiddenTerms(java.lang.String function, java.util.List<java.lang.Integer> replacementMap)
public void markVariables(java.util.List<java.lang.String> vars)
Term
variable
flags for the term and all of its subterms.
markVariables
in interface Term
vars
- The list of variables that shall be marked.public java.util.List<java.lang.Integer> getReplacementMap(java.lang.String function) throws AmbiguityException
Term
forbidden
flags of the
term and its subterms.
An empty list is returned for variables and constants and null in case
the symbol is not present in this term.
getReplacementMap
in interface Term
function
- The function whose replacement restrictions shall be returned.
AmbiguityException
- If the same function occurs with different
replacement restrictions. This indicates a missing invalidation
of the forbidden
flags of this terms earlier.public boolean isForbidden()
Term
forbidden
flag of this term.
isForbidden
in interface Term
forbidden
flag is set, False otherwise.public void setForbidden(boolean forbidden)
Term
forbidden
flag of this term.
setForbidden
in interface Term
forbidden
- The new value of the forbidden
flag.public boolean isVariable()
Term
variable
flag of this term.
isVariable
in interface Term
variable
flag is set, False otherwise.public void setVariable(boolean variable)
Term
variable
flag of this term.
setVariable
in interface Term
variable
- The new value of the variable
flag.public java.lang.String getFunction()
Term
getFunction
in interface Term
public void setFunction(java.lang.String function)
Term
setFunction
in interface Term
function
- Thee new (root) function symbol (or variable) of this term.public java.util.List<Term> getSubterms()
Term
getSubterms
in interface Term
public void setSubterms(java.util.List<Term> subterms)
Term
setSubterms
in interface Term
subterms
- The new (immediate) subterms of this term. May be null.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Set<java.lang.String> getVariables()
Term
variable
flags.
getVariables
in interface Term
public java.util.List<Term> getAllowedSubtermsWithRoot(java.util.List<java.lang.String> rootSymbols)
Term
forbidden
flags. The forbidden
flags
are preserved in the copies of the subterms.
getAllowedSubtermsWithRoot
in interface Term
rootSymbols
- The list of functions specifying the root symbols
of subterms that shall be returned.
public void markRoot()
Term
markRoot
in interface Term
public void demarkRoot()
Term
demarkRoot
in interface Term
public void instantiate(Substitution subst)
Term
instantiate
in interface Term
subst
- The substitution that is used for the instantiation.public boolean containsVariable(java.lang.String var)
Term
containsVariable
in interface Term
var
- The variable whose containment in the term shall be checked.
public void renameVariables()
Term
renameVariables()
on one of them. Rather you should
use code like the following for terms t1, t2
.
Set varIntersection = new HashSet(t1.getVariables);
while (!varIntersection.retainAll(t2.getVariables).isEmpty()) {
t1.renameVaribles();
varIntersection = new HashSet(t1.getVariables());
}
renameVariables
in interface Term
public void ren(java.lang.String var)
Term
ren
in interface Term
var
- The prefix for the new variable names, it
will be extended by a counter yielding the full
names of the new variables.public void cap(java.lang.String var, java.util.Collection<java.lang.String> definedFunctions)
Term
cap
in interface Term
var
- The prefix for the new variable names, it
will be extended by a counter yielding the full
names of the new variables.definedFunctions
- A collection of function symbols
defining the roots of subterms that are to be replaced.public void demarkVariables()
Term
demarkVariables
in interface Term
public boolean isLinear()
Term
isLinear
in interface Term
public java.util.Set<java.lang.String> getReplacingVariables()
Term
according
to the forbidden flags
of this term and its subterms. This function assumes
that this term itself is not forbidden, i.e. is not
subterm of some other term.
getReplacingVariables
in interface Term
public java.util.Set<java.lang.String> getHiddenSymbols()
Term
getHiddenSymbols
in interface Term
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.util.Set<Pair<Term,Substitution>> narrow(RewriteSystem trs, int variablePrefixCounter, boolean root, Strategy strat)
Term
forbidden
flags of this term and the given strategy
are coherent.
narrow
in interface Term
trs
- The Rewrite System that is used for the narrowing.variablePrefixCounter
- a number that is added as (additional)
prefix to the variables that are created in the process of narrowing
(through the variable renaming of the rules used for narrowing).
This parameter can be useful to prevent narrowings from terms
with disjoint variables from sharing variables, i.e. e.g. use a variable
prefix of 0 for the first narrowing process and 300 for the second one.
Alternatively you can rename the variables of narrowings by hand
(@see Term#renameVariables).root
- A boolean indicating whether root narrowing steps shall
be considered as well. True means that no root narrowings are considered.strat
- The Strategy that is used to set the forbidden
flags of the narrowings.
public void replaceVariable(java.lang.String oldVar, java.lang.String newVar)
Term
replaceVariable
in interface Term
oldVar
- The variable that is to be replaced.newVar
- The substitute variable.public boolean containsVariablePrefix(java.lang.String prefix)
Term
containsVariablePrefix
in interface Term
prefix
- The prefix whose presence shall be checked.
public java.util.Set<java.lang.String> getFunctions()
Term
getFunctions
in interface Term
public java.util.Set<Term> getSubtermsOfSignature(java.util.Set<java.lang.String> signature)
Term
Forbidden
flags are preserved in the copies of the subterms.
getSubtermsOfSignature
in interface Term
signature
- The signature identifying terms that shall be returned.
public boolean isSubterm(Term potentialSubterm)
Term
forbidden
flag is ignored when checking the
equalsity of the given term and the subterms of this term.
isSubterm
in interface Term
potentialSubterm
- The term that is checked for an occurrence as a subterm of this term.
public boolean isProperSubterm(Term potentialSubterm)
Term
forbidden
flag is ignored when checking the
equalsity of the given term and the subterms of this term.
isProperSubterm
in interface Term
potentialSubterm
- The term that is checked for an occurrence as a subterm of this term.
public java.util.Set<Pair<java.lang.String,java.lang.Integer>> getAllFunctionSymbolsWithArity()
Term
getAllFunctionSymbolsWithArity
in interface Term
public void filter(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> filtering)
Term
filter
in interface Term
filtering
- The filtering given by a mapping from functions to lists of argument positions.public boolean isNarrowable(RewriteSystem sys)
Term
forbidden
flags)
subterms can be narrowed according to the given Rewrite System R.
This function is used to check whether this term is a (context-sensitive)
Narrowing Normal Form w.r.t. R.
isNarrowable
in interface Term
sys
- The Rewrite System that is used for the narrowing.
public boolean hasConstructorContext(java.lang.String var, java.util.List<java.lang.String> definedSymbols)
Term
hasConstructorContext
in interface Term
var
- The variable that shall be checked for occurence in constructor contexts.definedSymbols
- The set of defined function symbols, and thus implicitly the
set of constructors.
public java.util.Set<Term> getAllForbiddenSubterms(boolean include)
Term
forbidden
flags.
getAllForbiddenSubterms
in interface Term
include
- Include this term in the list. If this flag is set all
subterms of this term are included as well. Call the function with true
only if the term on which it is called is forbidden.
In doubt set it to false.
public void removeContextSensitivityFlags()
Term
removeContextSensitivityFlags
in interface Term
public java.util.Set<java.lang.String> getNonReplacingVariables()
Term
getNonReplacingVariables
in interface Term
public java.util.Set<java.lang.String> getForbiddenFunctions()
Term
getForbiddenFunctions
in interface Term
public void substituteAt(java.util.List<java.lang.Integer> pos, Term substitute)
Term
substituteAt
in interface Term
pos
- The position of the subterm that is to be replacedsubstitute
- The term to be substituted
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |