Class AbstractMapBasedSubstitution

java.lang.Object
fr.lirmm.graphik.integraal.core.AbstractSubstitution
fr.lirmm.graphik.integraal.core.AbstractMapBasedSubstitution
All Implemented Interfaces:
Substitution, Comparable<Substitution>
Direct Known Subclasses:
HashMapSubstitution, TreeMapSubstitution

public abstract class AbstractMapBasedSubstitution extends AbstractSubstitution implements Substitution
Base substitution implementation backed by a map from variables to terms.
Author:
Clément Sipieter (INRIA) clement@6pi.fr
  • Constructor Details

    • AbstractMapBasedSubstitution

      protected AbstractMapBasedSubstitution()
      Creates a substitution backed by an implementation-defined map.
  • Method Details

    • getMap

      protected abstract Map<Variable,Term> getMap()
      Returns the mutable map that stores the substitution mappings.
      Returns:
      the backing map
    • getTerms

      public Set<Variable> getTerms()
      Description copied from interface: Substitution
      Get the domain of this substitution.
      Specified by:
      getTerms in interface Substitution
      Returns:
      the domain of this substitution.
    • getValues

      public Set<Term> getValues()
      Description copied from interface: Substitution
      Get the codomain of this substitution.
      Specified by:
      getValues in interface Substitution
      Returns:
      the codomain of this substitution.
    • createImageOf

      public Term createImageOf(Term term)
      Description copied from interface: Substitution
      Get the image of the given term by this substitution, if there is no image specified return the term itself.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      term - the term to substitute
      Returns:
      the image of the specified term.
    • put

      public boolean put(Variable term, Term substitute)
      Description copied from interface: Substitution
      Adds a mapping from the specified variable into the specified image to this substitution. Returns false if there already exists an other image for this variable, true otherwise.
      Specified by:
      put in interface Substitution
      Parameters:
      term - the variable to map
      substitute - the image of the variable
      Returns:
      true if the mapping was accepted, false otherwise
    • remove

      public boolean remove(Variable term)
      Description copied from interface: Substitution
      Remove the mapping for the specified variable.
      Specified by:
      remove in interface Substitution
      Parameters:
      term - the variable whose mapping must be removed
      Returns:
      true if there was a mapping.
    • aggregate

      public boolean aggregate(Variable term, Term substitut)
      Description copied from interface: Substitution
      The aggregation of a substitution is more complex that just add an new mapping for a new variable. Especially, it does not conserve the domain and codomain. It choose a representative term for each connected component by successive application of the mapping. For example, if the current substitution is {X -> Y, Z -> U} and you add a mapping {Y -> 'a', Z -> V}, the result is {Y -> 'a', X -> 'a', Z -> V, U -> V} or {Y -> 'a', X -> 'a', U -> Z, V -> Z} or {Y -> 'a', X -> 'a', Z -> U, V -> U}.
      Specified by:
      aggregate in interface Substitution
      Parameters:
      term - the variable to aggregate
      substitut - the image to aggregate with the variable
      Returns:
      false, if the aggregation put two constants into a same connected component.
    • appendTo

      void appendTo(StringBuilder sb)
      Appends this object representation to the provided builder.
      Parameters:
      sb - the target builder