Class Substitution
java.lang.Object
edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.operations.Substitution
This class represents a substitution of variables to terms. I.e., it is a mapping from variables to terms, where each
 variable can be mapped, at most, to one term.
- 
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptySubstitution.Substitution(Substitution toCopy) Constructs a newSubstitutionwith the same mappings as the specifiedSubstitution.Substitution(List<Term> domainTerms, List<Term> rangeTerms) Constructs a newSubstitutionthat maps each i-th term from domainTerms with the i-th rangeTerm. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddMapping(Variable domainVariable, Term rangeTerm) Modifies theSubstitutionadding a new mapping from the domainVariable to the rangeTerm.intgetSize()Returns substitution map size.Returns the image of theVariable.Returns all the variables appearing in the mappings (either in the domain or the range).booleanisEmpty()Returnstrueif this substitution contains no mappings.booleanReturnstrueif all mappings of the substitutions map variable to identical variables.booleanreplacesSomeVariableOf(Set<Variable> variables) Returnstrueif any of the variable from the input appear as the domain of a mapping.union(Substitution otherSubstitution) Constructs a newSubstitutionmaking the union between thisSubstitution, and the otherSubstitution. 
- 
Constructor Details
- 
Substitution
public Substitution()Constructs an emptySubstitution. - 
Substitution
Constructs a newSubstitutionwith the same mappings as the specifiedSubstitution.- Parameters:
 toCopy- the substitution whose mappings are to be placed in this substitution.- Throws:
 IllegalArgumentException- if toCopy parameter isnull.
 - 
Substitution
Constructs a newSubstitutionthat maps each i-th term from domainTerms with the i-th rangeTerm.If such
Substitutiondoes not exist, it throws aSubstitutionException. This could happen if the domainTerms contains aConstantin the i-th position and the rangeTerms has a different term (differentConstant, orVariable), in the i-th position.- Parameters:
 domainTerms- list ofTermwhich forms the domain of the substitution mapping.rangeTerms- list ofTermwhich forms the range of the substitution mapping.- Throws:
 IllegalArgumentException- if domainTerms or rangeTerms parameters arenull.SubstitutionException- if arity mismatch between domain and range or if domainConstantis mapped to differentConstantorVariable.
 
 - 
 - 
Method Details
- 
addMapping
Modifies theSubstitutionadding a new mapping from the domainVariable to the rangeTerm.- Parameters:
 domainVariable- domain variable to be mapped.rangeTerm- range term to be mapped.- Throws:
 IllegalArgumentException- if the domainVariableor the rangeTermarenull.SubstitutionException- if such mapping already exists in theSubstitution.
 - 
union
Constructs a newSubstitutionmaking the union between thisSubstitution, and the otherSubstitution.- Parameters:
 otherSubstitution- differentSubstitution.- Returns:
 - a new 
Substitutionas a union of substitutions. - Throws:
 IllegalArgumentException- if the otherSubstitutionisnull.SubstitutionException- if both substitutions try to map the same variable to different terms.
 - 
getTerm
Returns the image of theVariable.- Parameters:
 variable- domainVariable.- Returns:
 - the image of the 
Variable. - Throws:
 IllegalArgumentException- if input domainVariableisnull.
 - 
getSize
public int getSize()Returns substitution map size.- Returns:
 - substitution map size.
 
 - 
isEmpty
public boolean isEmpty()Returnstrueif this substitution contains no mappings.- Returns:
 trueif this substitution contains no mappings
 - 
replacesSomeVariableOf
Returnstrueif any of the variable from the input appear as the domain of a mapping.- Parameters:
 variables- set ofVariable.- Returns:
 trueif any of the variable from the input appear as the domain of a mapping.
 - 
getUsedVariables
Returns all the variables appearing in the mappings (either in the domain or the range).- Returns:
 - all the variables appearing in the mappings (either in the domain or the range).
 
 - 
isIdentity
public boolean isIdentity()Returnstrueif all mappings of the substitutions map variable to identical variables.- Returns:
 trueif all mappings of the substitutions map variable to identical variables.
 
 -