java.lang.Object
edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.operations.Substitution

public class Substitution extends Object
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 Details

    • Substitution

      public Substitution()
      Creates empty substitution
    • Substitution

      public Substitution(Substitution toCopy)
      Constructor by copy
      Parameters:
      toCopy - not null
    • Substitution

      public Substitution(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. 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 null
      rangeTerms - not null
  • Method Details

    • union

      public Substitution union(Substitution otherSubstitution)
      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

      public void 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 domainVariable
      Parameters:
      domainVariable - not null
      rangeTerm - not null
    • getTerm

      public Optional<Term> getTerm(Variable variable)
      Parameters:
      variable - not null
      Returns:
      the image of the variable
    • getSize

      public int getSize()
    • isEmpty

      public boolean isEmpty()
    • replacesSomeVariableOf

      public boolean replacesSomeVariableOf(Set<Variable> variables)
    • getUsedVariables

      public Set<Variable> getUsedVariables()
    • isIdentity

      public boolean isIdentity()
      Returns:
      whether the substitution replaces each variable for itself