|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Term
Class modelling a term. A term consists of a function symbol of a variable (String function
)
and a possibly empty list of subterms (List
). Whether the function is a variable or a
proper function symbol is indicated by a flag (boolean variable
).
Please make sure that no function symbol ends with a '#' character. Names
ending with such characters are reserved for dependency pair symbols.
Terms can be marked as forbidden (boolean forbidden
) in case a context-sensitive
strategy is used. This provides the computational convenience
of not checking the status explicitly every time it is needed. However,
the forbidden flags must be manually invalidated as soon as a subterm
is put out of its context.
Field Summary | |
---|---|
static java.lang.String |
NEW_VARIABLE_PREFIX
|
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). |
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. |
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 |
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. |
Field Detail |
---|
static final java.lang.String NEW_VARIABLE_PREFIX
Method Detail |
---|
void markForbiddenTerms(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> repMap)
repMap
- The replacement map specifying the replacement restrictions.void markVariables(java.util.List<java.lang.String> vars)
variable
flags for the term and all of its subterms.
vars
- The list of variables that shall be marked.java.util.List<java.lang.Integer> getReplacementMap(java.lang.String function) throws AmbiguityException
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.
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.boolean isForbidden()
forbidden
flag of this term.
forbidden
flag is set, False otherwise.void setForbidden(boolean forbidden)
forbidden
flag of this term.
forbidden
- The new value of the forbidden
flag.boolean isVariable()
variable
flag of this term.
variable
flag is set, False otherwise.void setVariable(boolean variable)
variable
flag of this term.
variable
- The new value of the variable
flag.java.lang.String getFunction()
void setFunction(java.lang.String function)
function
- Thee new (root) function symbol (or variable) of this term.java.util.List<Term> getSubterms()
void setSubterms(java.util.List<Term> subterms)
subterms
- The new (immediate) subterms of this term. May be null.java.util.Set<java.lang.String> getVariables()
variable
flags.
java.util.List<Term> getAllowedSubtermsWithRoot(java.util.List<java.lang.String> rootSymbols)
forbidden
flags. The forbidden
flags
are preserved in the copies of the subterms.
rootSymbols
- The list of functions specifying the root symbols
of subterms that shall be returned.
void markRoot()
void demarkRoot()
void instantiate(Substitution subst)
subst
- The substitution that is used for the instantiation.boolean containsVariable(java.lang.String var)
var
- The variable whose containment in the term shall be checked.
void renameVariables()
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());
}
void ren(java.lang.String var)
var
- The prefix for the new variable names, it
will be extended by a counter yielding the full
names of the new variables.void cap(java.lang.String var, java.util.Collection<java.lang.String> definedFunctions)
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.void demarkVariables()
boolean isLinear()
java.util.Set<java.lang.String> getReplacingVariables()
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.
java.util.Set<java.lang.String> getNonReplacingVariables()
java.util.Set<java.lang.String> getHiddenSymbols()
java.util.Set<Pair<Term,Substitution>> narrow(RewriteSystem trs, int variablePrefixCounter, boolean root, Strategy strat)
forbidden
flags of this term and the given strategy
are coherent.
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.
void replaceVariable(java.lang.String oldVar, java.lang.String newVar)
oldVar
- The variable that is to be replaced.newVar
- The substitute variable.boolean containsVariablePrefix(java.lang.String prefix)
prefix
- The prefix whose presence shall be checked.
java.util.Set<java.lang.String> getFunctions()
java.util.Set<Term> getSubtermsOfSignature(java.util.Set<java.lang.String> signature)
Forbidden
flags are preserved in the copies of the subterms.
signature
- The signature identifying terms that shall be returned.
boolean isSubterm(Term potentialSubterm)
forbidden
flag is ignored when checking the
equalsity of the given term and the subterms of this term.
potentialSubterm
- The term that is checked for an occurrence as a subterm of this term.
boolean isProperSubterm(Term potentialSubterm)
forbidden
flag is ignored when checking the
equalsity of the given term and the subterms of this term.
potentialSubterm
- The term that is checked for an occurrence as a subterm of this term.
java.util.Set<Pair<java.lang.String,java.lang.Integer>> getAllFunctionSymbolsWithArity()
void filter(java.util.Map<java.lang.String,java.util.List<java.lang.Integer>> filtering)
filtering
- The filtering given by a mapping from functions to lists of argument positions.boolean isNarrowable(RewriteSystem sys)
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.
sys
- The Rewrite System that is used for the narrowing.
boolean hasConstructorContext(java.lang.String var, java.util.List<java.lang.String> definedSymbols)
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.
java.util.Set<Term> getAllForbiddenSubterms(boolean include)
forbidden
flags.
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.
void removeContextSensitivityFlags()
java.util.Set<java.lang.String> getForbiddenFunctions()
void substituteAt(java.util.List<java.lang.Integer> pos, Term substitute)
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 |