Interface Substitution

All Superinterfaces:
fr.inria.rules.dlgpemodel.api.sentences.IPrintable, fr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term>
All Known Implementing Classes:
SubstitutionImpl

public interface Substitution extends fr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term>
A substitution is an application from a set of variables into a set of terms.
Author:
Florent Tornil, Guillaume Perution-Kihli
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Substitution
    Shared empty substitution instance.

    Fields inherited from interface fr.inria.rules.dlgpemodel.api.sentences.IPrintable

    WRITER
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Variable v, Term t)
    Adds a mapping from the specified variable into the specified image to this substitution.
    The aggregation of a substitution is more complex that just add a new mapping for a new variable.
    default <R> R
    createImageOf(Substitutable<R> substitutable)
    Applies this substitution to a Substitutable object.
    default <R> R
    createImageOf(Substitutable<R> substitutable, boolean evaluate)
    Applies this substitution to a Substitutable object.
    Retrieves the term mapped to a specific variable in this substitution.
    boolean
    Indicates whether this substitution contains no mappings.
    boolean
    Checks whether another substitution is included in this one.
    boolean
    Indicates whether this substitution is injective.
    boolean
    Indicates whether this substitution can be inverted as a substitution.
    Get the domain of this substitution.
    Returns a copy of this substitution restricted to the supplied variables.
    default boolean
    Checks whether all mapped variables resolve to constants.
    default boolean
    Checks whether the selected variables resolve to constants.
    Two substitutions can be merged iff for each key in common, the image is the same
    boolean
    Attempts to merge other into this substitution in-place.
    Returns the range terms of this substitution.
    void
    Remove the given variable affectation from this substitution
    default void
    Remove the variables that are sent into themselves
    Convert the substitution to a map

    Methods inherited from interface fr.inria.rules.dlgpemodel.api.sentences.IPrintable

    toDLGPE
  • Field Details

    • EMPTY

      static final Substitution EMPTY
      Shared empty substitution instance.
  • Method Details

    • createImageOf

      default <R> R createImageOf(Substitutable<R> substitutable, boolean evaluate)
      Applies this substitution to a Substitutable object.
      Type Parameters:
      R - the type of the substitutable object
      Parameters:
      substitutable - the object to apply the substitution on
      evaluate - if true forces the evaluation of terms that are evaluable functions
      Returns:
      the substituted object of type R
    • createImageOf

      default <R> R createImageOf(Substitutable<R> substitutable)
      Applies this substitution to a Substitutable object.
      Type Parameters:
      R - the type of the substitutable object
      Parameters:
      substitutable - the object to apply the substitution on
      Returns:
      the substituted object of type R
    • getImageOfVariable

      Term getImageOfVariable(Variable variable)
      Retrieves the term mapped to a specific variable in this substitution.
      Specified by:
      getImageOfVariable in interface fr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term>
      Parameters:
      variable - the variable to substitute
      Returns:
      the image of the variable
    • keys

      Get the domain of this substitution.
      Specified by:
      keys in interface fr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term>
      Returns:
      the domain of this substitution.
    • add

      void add(Variable v, Term t)
      Adds a mapping from the specified variable into the specified image to this substitution.
      Parameters:
      v - the key
      t - the image
    • merged

      Two substitutions can be merged iff for each key in common, the image is the same
      Parameters:
      other - a substitution
      Returns:
      a new substitution being the merge of this one and the other one or an empty optional if the substitutions are not compatible
    • mergeInPlace

      boolean mergeInPlace(Substitution other)
      Attempts to merge other into this substitution in-place.

      A merge succeeds iff, for every variable appearing in both substitutions, the two images are equal. – On success : the new (compatible) bindings from other are copied inside this and the method returns true. – On failure : this is left exactly in its original state and the method returns false.

      Side effects : the operation mutates this only when it succeeds.

      Parameters:
      other - a substitution to merge
      Returns:
      true on success, false if a conflict is detected
    • limitedTo

      Substitution limitedTo(Collection<Variable> vars)
      Returns a copy of this substitution restricted to the supplied variables.
      Parameters:
      vars - variables to limit to
      Returns:
      a new substitution identical to this one but limited to a subset of variables
    • isExtensionOf

      boolean isExtensionOf(Substitution other)
      Checks whether another substitution is included in this one.
      Parameters:
      other - a substitution
      Returns:
      true iff the other substitution is included into this one
    • aggregated

      The aggregation of a substitution is more complex that just add a new mapping for a new variable. Especially, it does not conserve the domain and codomain. It chooses 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:
      s - the substitution to aggregate with
      Returns:
      the aggregated substitution or an empty optional if it is not possible
    • remove

      void remove(Variable v)
      Remove the given variable affectation from this substitution
      Parameters:
      v - a variable
    • isEmpty

      boolean isEmpty()
      Indicates whether this substitution contains no mappings.
      Returns:
      true iff this substitution is empty
    • mapsToConstantsOnly

      default boolean mapsToConstantsOnly()
      Checks whether all mapped variables resolve to constants.
      Returns:
      true if the image of variables in this substitution are constants
    • mapsToConstantsOnly

      default boolean mapsToConstantsOnly(Collection<Variable> variableSet)
      Checks whether the selected variables resolve to constants.
      Parameters:
      variableSet - of variables which must map to constants only
      Returns:
      true if the image of variables in this substitution are constants
    • isInjective

      boolean isInjective()
      Indicates whether this substitution is injective.
      Returns:
      true iff this substitution is injective
    • isInvertible

      boolean isInvertible()
      Indicates whether this substitution can be inverted as a substitution.
      Returns:
      true iff the inverse of this substitution is a substitution
    • rangeTerms

      Set<Term> rangeTerms()
      Returns the range terms of this substitution.
      Returns:
      all range term of the substitution
    • removeIdentity

      default void removeIdentity()
      Remove the variables that are sent into themselves
    • toMap

      Map<Variable,Term> toMap()
      Convert the substitution to a map
      Returns:
      A map that represents the substitution