Module logicng

Class Substitution


  • public final class Substitution
    extends Object
    A Boolean substitution.
    Since:
    1.0
    Version:
    2.0.0
    • Constructor Detail

      • Substitution

        public Substitution()
        Constructs a new empty substitution.
      • Substitution

        public Substitution​(Substitution other)
        Constructs a new substitution by copying the given one.
        Parameters:
        other - the substitution to copy
      • Substitution

        public Substitution​(Map<Variable,​Formula> mapping)
        Constructs a new substitution and initializes it with the given mapping.
        Parameters:
        mapping - the initial mapping
    • Method Detail

      • size

        public int size()
        Returns the number of mappings in this substitution.
        Returns:
        the number of mappings in this substitution
      • addMapping

        public void addMapping​(Variable variable,
                               Formula formula)
        Adds a mapping from variable to formula to this substitution.

        If there is already a mapping for this variable, it will be overwritten.

        Parameters:
        variable - the variable
        formula - the formula
      • getSubstitution

        public Formula getSubstitution​(Variable variable)
        Returns a formula for a given variable. If there is no mapping for this variable, null is returned.
        Parameters:
        variable - the variable
        Returns:
        a formula or null
      • getMapping

        public Map<Variable,​Formula> getMapping()
        Returns an unmodifiable reference to the internal mapping of variables to formulas.
        Returns:
        the internal mapping of variables to formulas
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object