Module logicng

Class PrimeCompiler


  • public final class PrimeCompiler
    extends Object
    Compiler for prime implicants and prime implicates of formulas.

    Implementation is based on "Prime compilation of non-clausal formulae", (Previti, Ignatiev, Morgado, & Marques-Silva, 2015).

    The algorithm computes either all prime implicants and a cover of prime implicates or a cover of prime implicants and all prime implicates. This can be configured via the PrimeResult.CoverageType.

    Furthermore, the algorithm comes in two flavors: One which searches for maximum models getWithMaximization() and another which searches for minimum models getWithMaximization(). From experience, the one with minimum models usually outperforms the one with maximum models.

    Since:
    2.0.0
    Version:
    2.1.0
    • Method Detail

      • getWithMinimization

        public static PrimeCompiler getWithMinimization()
        Returns a compiler which uses minimum models to compute the primes.
        Returns:
        a compiler which uses minimum models to compute the primes
      • getWithMaximization

        public static PrimeCompiler getWithMaximization()
        Returns a compiler which uses maximum models to compute the primes.
        Returns:
        a compiler which uses maximum models to compute the primes
      • compute

        public PrimeResult compute​(Formula formula,
                                   PrimeResult.CoverageType type)
        Computes prime implicants and prime implicates for a given formula. The coverage type specifies if the implicants or the implicates will be complete, the other one will still be a cover of the given formula.
        Parameters:
        formula - the formula
        type - the coverage type
        Returns:
        the prime result
      • compute

        public PrimeResult compute​(Formula formula,
                                   PrimeResult.CoverageType type,
                                   OptimizationHandler handler)
        Computes prime implicants and prime implicates for a given formula. The coverage type specifies if the implicants or the implicates will be complete, the other one will still be a cover of the given formula.

        The prime compiler can be called with an OptimizationHandler. The given handler instance will be used for every subsequent OptimizationFunction call and the handler's SAT handler is used for every subsequent SAT call.

        Parameters:
        formula - the formula
        type - the coverage type
        handler - an optimization handler, can be null
        Returns:
        the prime result or null if the computation was aborted by the handler