Module logicng

Class LiteralSubstitution

  • All Implemented Interfaces:
    FormulaTransformation

    public final class LiteralSubstitution
    extends Object
    implements FormulaTransformation
    A formula transformation which substitutes literals by other literals.

    Always the best fit is chosen. So if there are two mappings for e.g. a -> b and ~a -> c. Then ~a will be mapped to c and not to ~b. On the other hand if there is only the mapping a -> b, the literal ~a will be mapped to ~b.

    Since:
    2.0.0
    Version:
    2.0.0
    • Constructor Detail

      • LiteralSubstitution

        public LiteralSubstitution​(Map<Literal,​Literal> substitution)
        Generate a new formula substitution with a given literal-to-literal mapping.
        Parameters:
        substitution - a mapping from literals to literals
      • LiteralSubstitution

        public LiteralSubstitution()
        Generates a new formula substitution with an empty literal mapping.
    • Method Detail

      • addSubstitution

        public void addSubstitution​(Literal from,
                                    Literal to)
        Adds a new literal mapping to this substitution.
        Parameters:
        from - the literal which should be substituted
        to - the literal with which the substituted literal should be replaced
      • apply

        public Formula apply​(Formula formula,
                             boolean cache)
        Description copied from interface: FormulaTransformation
        Returns the transformed formula.
        Specified by:
        apply in interface FormulaTransformation
        Parameters:
        formula - the input formula
        cache - indicated whether the result (and associated predicates) should be cached in the formula's cache.
        Returns:
        the transformed formula