- java.lang.Object
-
- org.chocosolver.solver.constraints.nary.cnf.LogicTreeToolBox
-
public class LogicTreeToolBox extends Object
A tool box to convert logical expressions into CNF.- Since:
- 23 nov. 2010
- Author:
- Charles Prud'homme, Xavier Lorca
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LogicTreeToolBox()
This class is a factory, no need to create it.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LogOp
developOr(LogOp n)
Moves down 'OR' operand in the logical expressionn
.static LogOp
distribute(LogOp n)
Distributes 'OR's inwards over 'AND's inn
static void
expandNot(LogOp n)
Erases 'NOT' operand from the logical expressionn
by flipping the right childrenstatic void
merge(LogOp.Operator op, LogOp n)
Flattens a logical expressionn
based on operatorop
.static ILogical
simplify(ILogical t, Model model)
Detects tautologies and contradictions fromt
static ILogical
simplifySingleton(ILogical l, Model model)
Remove tautologies froml
static ILogical
toCNF(LogOp logOp, Model model)
Warning: if there is a bug, please check the CNF build is like: - lit OR lit ...
-
-
-
Method Detail
-
toCNF
public static ILogical toCNF(LogOp logOp, Model model)
Warning: if there is a bug, please check the CNF build is like: - lit OR lit ... OR lit - (lit OR lit ... OR lit) AND (lit OR lit ... OR lit) ... AND (lit OR lit ... OR lit)- Parameters:
logOp
- logical operatormodel
- the model in which the logical expression will be added, useful since the expression may only be made of TRUE and FALSE.- Returns:
- a CNF logical expression
-
expandNot
public static void expandNot(LogOp n)
Erases 'NOT' operand from the logical expressionn
by flipping the right children- Parameters:
n
- a logical expression
-
merge
public static void merge(LogOp.Operator op, LogOp n)
Flattens a logical expressionn
based on operatorop
. Transform from undefined depth expression to comb expression- Parameters:
op
- reference operatorn
- the lofical expression
-
developOr
public static LogOp developOr(LogOp n)
Moves down 'OR' operand in the logical expressionn
.- Parameters:
n
- a logical expression- Returns:
- the modified logical expression
-
distribute
public static LogOp distribute(LogOp n)
Distributes 'OR's inwards over 'AND's inn
- Parameters:
n
- a logical expression- Returns:
- the modified logical expression
-
simplify
public static ILogical simplify(ILogical t, Model model)
Detects tautologies and contradictions fromt
- Parameters:
t
- a logical expressionmodel
- to getIVariableFactory.boolVar(boolean)
.- Returns:
- simplified logical expression
-
simplifySingleton
public static ILogical simplifySingleton(ILogical l, Model model)
Remove tautologies froml
- Parameters:
l
- logical expressionmodel
- to getIVariableFactory.intVar(int)
.- Returns:
- simplified logical expression
-
-