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
ConstructorDescriptionCreates empty substitutionSubstitution
(Substitution toCopy) Constructor by copySubstitution
(List<Term> domainTerms, List<Term> rangeTerms) Creates a Substitution that replaces each i-th term from domainTerms to unify with the i-th rangeTerm If such substitution does not exist, it throws a SubstitutionException. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapping
(Variable domainVariable, Term rangeTerm) Include in this substitution a new mapping from the domainVariable to the rangeTerm If such mapping already exists, it throws a SubstitutionException if the rangeTerm is different compared to the current image of the domainVariableint
getSize()
boolean
isEmpty()
boolean
boolean
replacesSomeVariableOf
(Set<Variable> variables) union
(Substitution otherSubstitution) Creates a new Substitution making the union between this Substitution, and the otherSubstitution.
-
Constructor Details
-
Substitution
public Substitution()Creates empty substitution -
Substitution
Constructor by copy- Parameters:
toCopy
- not null
-
Substitution
Creates a Substitution that replaces each i-th term from domainTerms to unify with the i-th rangeTerm If such substitution does not exist, it throws a SubstitutionException. Such substitution might not exist, for instance, if the domainTerms contains a constant in the i-th position, and the rangeTerms has a different term (different constant, or variable), in the i-th position.- Parameters:
domainTerms
- not nullrangeTerms
- not null
-
-
Method Details
-
union
Creates a new Substitution making the union between this Substitution, and the otherSubstitution. If both substitutions try to map the same variable to different terms, it throws an exception.- Parameters:
otherSubstitution
- not null- Returns:
- a union of substitutions
-
addMapping
Include in this substitution a new mapping from the domainVariable to the rangeTerm If such mapping already exists, it throws a SubstitutionException if the rangeTerm is different compared to the current image of the domainVariable- Parameters:
domainVariable
- not nullrangeTerm
- not null
-
getTerm
- Parameters:
variable
- not null- Returns:
- the image of the variable
-
getSize
public int getSize() -
isEmpty
public boolean isEmpty() -
replacesSomeVariableOf
-
getUsedVariables
-
isIdentity
public boolean isIdentity()- Returns:
- whether the substitution replaces each variable for itself
-