Module logicng

Class Anonymizer

  • All Implemented Interfaces:
    FormulaTransformation

    public final class Anonymizer
    extends Object
    implements FormulaTransformation
    An anonymizer replaces all variables in a formula with new variables generated from a given prefix and a counter.

    An instance can be used to anonymize multiple formulas. In this case, variables with the same name will be replaced with the same anonymized variable.

    After anonymizing one or more formulas, the mapping from original variable to anonymized variable can be accessed via getSubstitution().

    Since:
    1.4.0
    Version:
    1.4.0
    • Constructor Detail

      • Anonymizer

        public Anonymizer​(String prefix,
                          int startCounter)
        Constructs a new anonymizer with a given prefix for the newly introduced variables.
        Parameters:
        prefix - the prefix for the new variables
        startCounter - where should the counter start
      • Anonymizer

        public Anonymizer​(String prefix)
        Constructs a new anonymizer with a given prefix for the newly introduced variables.
        Parameters:
        prefix - the prefix for the new variables
      • Anonymizer

        public Anonymizer()
        Constructs a new anonymizer with the standard variable prefix 'v'.
    • Method Detail

      • getSubstitution

        public Substitution getSubstitution()
        Returns the substitution which was used to anonymize the formula(s).

        Although a substitution maps from variables to formulas, it is guaranteed that the substitution always maps to variables. So the following cast will always be safe:

        (Variable) getSubstitution().getSubstitution(x)

        Returns:
        the substitution which was used to anonymize the formula(s)
      • 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