Module logicng

Class DnnfMiniSatStyleSolver

  • All Implemented Interfaces:
    DnnfSatSolver

    public class DnnfMiniSatStyleSolver
    extends MiniSat2Solver
    implements DnnfSatSolver
    A variation of the MiniSat solver used during the DNNF compilation process.
    Since:
    2.0.0
    Version:
    2.0.0
    • Field Detail

      • newlyImpliedDirty

        protected boolean newlyImpliedDirty
      • assertionLevel

        protected int assertionLevel
      • assignment

        protected final Tristate[] assignment
      • impliedOperands

        protected final List<Literal> impliedOperands
    • Constructor Detail

      • DnnfMiniSatStyleSolver

        public DnnfMiniSatStyleSolver​(FormulaFactory f,
                                      int numberOfVariables)
        Constructs a new DNNF MiniSat solver with the given number of variables.
        Parameters:
        f - the formula factory
        numberOfVariables - the number of variables
    • Method Detail

      • start

        public boolean start()
        Description copied from interface: DnnfSatSolver
        Initializes the solver by performing unit propagation and returns false if UP finds a contradiction, otherwise true.
        Specified by:
        start in interface DnnfSatSolver
        Returns:
        false if UP finds a contradiction, otherwise true
      • valueOf

        public Tristate valueOf​(int lit)
        Description copied from interface: DnnfSatSolver
        Returns the current assignment of the given literal.
        Specified by:
        valueOf in interface DnnfSatSolver
        Parameters:
        lit - the literal
        Returns:
        the current assignment of the given literal
      • variableIndex

        public int variableIndex​(Literal lit)
        Description copied from interface: DnnfSatSolver
        Returns the index of the variable of the given literal.
        Specified by:
        variableIndex in interface DnnfSatSolver
        Parameters:
        lit - the literal
        Returns:
        the index of the literal's variable
      • litForIdx

        public Literal litForIdx​(int var)
        Description copied from interface: DnnfSatSolver
        Returns the literal corresponding to the given variable index.
        Specified by:
        litForIdx in interface DnnfSatSolver
        Parameters:
        var - the variable index
        Returns:
        the literal corresponding to the given variable index
      • var

        public static int var​(int lit)
        Returns the variable index for a given literal.
        Parameters:
        lit - the literal
        Returns:
        the variable index of the literal
      • phase

        public static boolean phase​(int lit)
        Returns the phase of the given solver literal.
        Parameters:
        lit - the solver literal
        Returns:
        true if the literal has a positive phase, false if the literal has a negative phase (literal is negated)
      • add

        public void add​(Formula formula)
        Description copied from interface: DnnfSatSolver
        Adds a formula to the solver. The formula is first converted to CNF.
        Specified by:
        add in interface DnnfSatSolver
        Parameters:
        formula - the formula
      • decide

        public boolean decide​(int var,
                              boolean phase)
        Description copied from interface: DnnfSatSolver
        Performs a decision of the given variable to the given phase and performs UP.
        Specified by:
        decide in interface DnnfSatSolver
        Parameters:
        var - the variable
        phase - the phase
        Returns:
        false if UP finds a contradiction, otherwise true
      • undoDecide

        public void undoDecide​(int var)
        Description copied from interface: DnnfSatSolver
        Reverts the decision of the given variable.
        Specified by:
        undoDecide in interface DnnfSatSolver
        Parameters:
        var - the variable
      • atAssertionLevel

        public boolean atAssertionLevel()
        Description copied from interface: DnnfSatSolver
        Returns true if the current decision level was previously selected as backtrack level.
        Specified by:
        atAssertionLevel in interface DnnfSatSolver
        Returns:
        true if the current decision level was previously selected as backtrack level, otherwise false
      • assertCdLiteral

        public boolean assertCdLiteral()
        Description copied from interface: DnnfSatSolver
        Enqueues the literal which was computed by the latest backtracking, performs UP and return false if UP finds a contradiction, otherwise true.
        Specified by:
        assertCdLiteral in interface DnnfSatSolver
        Returns:
        false if UP finds a contradiction, otherwise true
      • newlyImplied

        public Formula newlyImplied​(BitSet knownVariables)
        Description copied from interface: DnnfSatSolver
        Returns a conjunction of all literals in the known variables which were propagated by the last UP.
        Specified by:
        newlyImplied in interface DnnfSatSolver
        Parameters:
        knownVariables - the known variables
        Returns:
        a conjunction of the relevant propagated literals
      • intToLiteral

        protected Literal intToLiteral​(int lit)
      • propagateAfterDecide

        protected boolean propagateAfterDecide()
      • uncheckedEnqueue

        protected void uncheckedEnqueue​(int lit,
                                        MSClause reason)
        Description copied from class: MiniSatStyleSolver
        Assigns a literal (= a variable to the respective value).
        Overrides:
        uncheckedEnqueue in class MiniSat2Solver
        Parameters:
        lit - the literal
        reason - the reason clause of the assignment (conflict resolution) or null if it was a decision
      • handleConflict

        protected void handleConflict​(MSClause conflict)