- java.lang.Object
-
- org.logicng.transformations.cnf.CNFEncoder
-
public class CNFEncoder extends Object
An encoder for conjunctive normal form (CNF).- Since:
- 1.1
- Version:
- 2.3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classCNFEncoder.AdvancedFactorizationHandlerThe factorization handler for the advanced CNF encoding.
-
Field Summary
Fields Modifier and Type Field Description protected CNFFactorizationadvancedFactorizationprotected BDDCNFTransformationbddCnfTransformationprotected CNFConfigconfigprotected intcurrentAtomBoundaryprotected FormulaFactoryfprotected CNFFactorizationfactorizationprotected CNFEncoder.AdvancedFactorizationHandlerfactorizationHandlerprotected PlaistedGreenbaumTransformationplaistedGreenbaumprotected TseitinTransformationtseitin
-
Constructor Summary
Constructors Constructor Description CNFEncoder(FormulaFactory f)Constructs a new CNF encoder which uses the configuration of the formula factory.CNFEncoder(FormulaFactory f, CNFConfig config)Constructs a new CNF encoder with a given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected FormulaadvancedEncoding(Formula formula)Encodes the given formula to CNF by first trying to use Factorization for the single sub-formulas.CNFConfigconfig()Returns the current configuration of this encoder.Formulaencode(Formula formula)Encodes a formula to CNF.protected FormulasingleAdvancedEncoding(Formula formula)StringtoString()
-
-
-
Field Detail
-
f
protected final FormulaFactory f
-
config
protected final CNFConfig config
-
factorization
protected CNFFactorization factorization
-
advancedFactorization
protected CNFFactorization advancedFactorization
-
bddCnfTransformation
protected BDDCNFTransformation bddCnfTransformation
-
tseitin
protected TseitinTransformation tseitin
-
plaistedGreenbaum
protected PlaistedGreenbaumTransformation plaistedGreenbaum
-
currentAtomBoundary
protected int currentAtomBoundary
-
factorizationHandler
protected CNFEncoder.AdvancedFactorizationHandler factorizationHandler
-
-
Constructor Detail
-
CNFEncoder
public CNFEncoder(FormulaFactory f, CNFConfig config)
Constructs a new CNF encoder with a given configuration.- Parameters:
f- the formula factoryconfig- the configuration
-
CNFEncoder
public CNFEncoder(FormulaFactory f)
Constructs a new CNF encoder which uses the configuration of the formula factory.- Parameters:
f- the formula factory
-
-
Method Detail
-
encode
public Formula encode(Formula formula)
Encodes a formula to CNF.- Parameters:
formula- formula- Returns:
- the CNF encoding of the formula
-
advancedEncoding
protected Formula advancedEncoding(Formula formula)
Encodes the given formula to CNF by first trying to use Factorization for the single sub-formulas. When certain user-provided boundaries are met, the method is switched to Tseitin or Plaisted & Greenbaum.- Parameters:
formula- the formula- Returns:
- the CNF encoding of the formula
-
config
public CNFConfig config()
Returns the current configuration of this encoder. If the encoder was constructed with a given configuration, this configuration will always be used. Otherwise, the current configuration from the formula factory is used.- Returns:
- the current configuration of
-
-