- java.lang.Object
-
- org.logicng.predicates.EvaluatesToConstantPredicate
-
- All Implemented Interfaces:
FormulaPredicate
public final class EvaluatesToConstantPredicate extends Object implements FormulaPredicate
Checks if the given formula is evaluated to false/true for a given (partial) assignment.Note: If a partial assignment is given, the check only recognizes simple unsatisfiable/tautology cases
- operand of an AND/OR is false/true
- all operators of an OR/AND are false/true
- AND/OR has two operands with complementary negations
Formula.evaluate(Assignment)in two ways. It accepts partial assignments, and it tries to avoid the generation of intermediate formula by the formula factory objects in order to speed up the performance.Example 01: When evaluation to false the formula (a | b) & (~a | c) with partial assignment [b -> false, c -> false] yields to a & ~a which is recognized as unsatisfiable.
Example 02: When evaluation to true the formula (a & b) | (~a & c) with partial assignment [b -> false, c -> false] yields to a | ~a which is recognized as a tautology.
- Since:
- 2.0.0
- Version:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description EvaluatesToConstantPredicate(boolean evaluatesToTrue, Map<Variable,Boolean> mapping)Constructs a new evaluation predicate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Variable,Boolean>getMapping()Returns the (partial) assignment.booleantest(Formula formula, boolean caching)Checks if the formula evaluates to false (or true) when the (partial) assignment is applied.
-
-
-
Method Detail
-
getMapping
public Map<Variable,Boolean> getMapping()
Returns the (partial) assignment.- Returns:
- the (partial) assignment
-
test
public boolean test(Formula formula, boolean caching)
Checks if the formula evaluates to false (or true) when the (partial) assignment is applied.- Specified by:
testin interfaceFormulaPredicate- Parameters:
formula- the formulacaching- indicator for caching (currently not used)- Returns:
trueif applying the (partial) assignment yields to the specified constant, otherwisefalse
-
-