Interface Substitution

All Superinterfaces:
Comparable<Substitution>
All Known Implementing Classes:
AbstractMapBasedSubstitution, AbstractSubstitution, EmptySubstitution, FreshVarSubstitution, HashMapSubstitution, TreeMapSubstitution, VariablePrefixSubstitution, VariableRemovePrefixSubstitution

public interface Substitution extends Comparable<Substitution>
A substitution is an application from a set of variables into a set of terms.
Author:
Clément Sipieter (INRIA) <clement@6pi.fr>
  • Method Details

    • getTerms

      Set<Variable> getTerms()
      Get the domain of this substitution.
      Returns:
      the domain of this substitution.
    • getValues

      Set<Term> getValues()
      Get the codomain of this substitution.
      Returns:
      the codomain of this substitution.
    • createImageOf

      Term createImageOf(Term term)
      Get the image of the given term by this substitution, if there is no image specified return the term itself.
      Parameters:
      term - the term to substitute
      Returns:
      the image of the specified term.
    • createImageOf

      List<Term> createImageOf(Collection<? extends Term> terms)
      Get the image of each terms of the specified list.
      Parameters:
      terms - the terms to substitute
      Returns:
      A list of images of each terms.
    • put

      boolean put(Variable var, Term image)
      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.
      Parameters:
      var - the variable to map
      image - the image of the variable
      Returns:
      true if the mapping was accepted, false otherwise
    • put

      boolean put(Substitution s)
      Add all mappings from an other substitution instance. Returns false if there already exists an other image for a variable from the domain of s, true otherwise.
      Parameters:
      s - the substitution whose mappings should be inserted
      Returns:
      false if there already exists an other image for a variable from the domain of s, true otherwise.
    • remove

      boolean remove(Variable var)
      Remove the mapping for the specified variable.
      Parameters:
      var - the variable whose mapping must be removed
      Returns:
      true if there was a mapping.
    • aggregate

      boolean aggregate(Variable var, Term image)
      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}.
      Parameters:
      var - the variable to aggregate
      image - the image to aggregate with the variable
      Returns:
      false, if the aggregation put two constants into a same connected component.
    • aggregate

      Substitution aggregate(Substitution s)
      (const) This method construct a new Substitution which is the aggregation of this substitution with the specified one.
      Parameters:
      s - the substitution to aggregate with this one
      Returns:
      null, if the aggregation put two constants into a same connected component.
    • compose

      boolean compose(Variable term, Term substitut)
      For example, if the current substitution is {Y -> Z} and you compose it with {X -> Y, V -> U}, the result is {X -> Z, Y -> Z, V -> U}.
      Parameters:
      term - the variable to compose
      substitut - the image to compose with
      Returns:
      true if the composition succeeds, false otherwise
    • compose

      (CONST)
      This method construct a new Substitution which is the composition of this substitution with the specified one. For example, if the current substitution is {Y -> Z} and you compose it with {X -> Y, V -> U}, the result is {X -> Z, Y -> Z, V -> U}.
      Parameters:
      s - the substitution to compose with this one
      Returns:
      the composed substitution
    • createImageOf

      Atom createImageOf(Atom atom)
      Apply this substitution on an atom.
      Parameters:
      atom - (const)
      Returns:
      an Atom which is the image of specified one by this substitution.
    • createImageOf

      InMemoryAtomSet createImageOf(AtomSet src) throws AtomSetException
      Apply this substitution on an atom set.
      Parameters:
      src - (const)
      Returns:
      an InMemoryAtomSet which is the image of specified one by this substitution.
      Throws:
      AtomSetException - if the image cannot be computed
    • createImageOf

      InMemoryAtomSet createImageOf(InMemoryAtomSet src)
      Apply this substitution on an atom set.
      Parameters:
      src - (const)
      Returns:
      an InMemoryAtomSet which is the image of specified one by this substitution.
    • createImageOf

      Rule createImageOf(Rule rule)
      Apply this substitution on the given rule.
      Parameters:
      rule - (const)
      Returns:
      an Rule which is the image of specified one by this substitution.
    • createImageOf

      Apply this substitution on the given conjunctive query.
      Parameters:
      cq - (const)
      Returns:
      an conjunctive query which is the image of specified one by this substitution.
    • apply

      void apply(AtomSet src, AtomSet target) throws AtomSetException
      Insert the application of this substitution on the src atom set into the target atom set.
      Parameters:
      src - (const)
      target - the atom set receiving the substituted atoms
      Throws:
      AtomSetException - if the substituted atoms cannot be inserted
    • apply

      void apply(InMemoryAtomSet src, InMemoryAtomSet target)
      Insert the application of this substitution on the src atom set into the target atom set.
      Parameters:
      src - (const)
      target - the atom set receiving the substituted atoms
    • appendTo

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