- java.lang.Object
-
- org.logicng.transformations.LiteralSubstitution
-
- All Implemented Interfaces:
FormulaTransformation
public final class LiteralSubstitution extends Object implements FormulaTransformation
A formula transformation which substitutes literals by other literals.Always the best fit is chosen. So if there are two mappings for e.g.
a -> band~a -> c. Then~awill be mapped tocand not to~b. On the other hand if there is only the mappinga -> b, the literal~awill be mapped to~b.- Since:
- 2.0.0
- Version:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description LiteralSubstitution()Generates a new formula substitution with an empty literal mapping.LiteralSubstitution(Map<Literal,Literal> substitution)Generate a new formula substitution with a given literal-to-literal mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSubstitution(Literal from, Literal to)Adds a new literal mapping to this substitution.Formulaapply(Formula formula, boolean cache)Returns the transformed formula.
-
-
-
Constructor Detail
-
LiteralSubstitution
public LiteralSubstitution(Map<Literal,Literal> substitution)
Generate a new formula substitution with a given literal-to-literal mapping.- Parameters:
substitution- a mapping from literals to literals
-
LiteralSubstitution
public LiteralSubstitution()
Generates a new formula substitution with an empty literal mapping.
-
-
Method Detail
-
addSubstitution
public void addSubstitution(Literal from, Literal to)
Adds a new literal mapping to this substitution.- Parameters:
from- the literal which should be substitutedto- the literal with which the substituted literal should be replaced
-
apply
public Formula apply(Formula formula, boolean cache)
Description copied from interface:FormulaTransformationReturns the transformed formula.- Specified by:
applyin interfaceFormulaTransformation- Parameters:
formula- the input formulacache- indicated whether the result (and associated predicates) should be cached in the formula's cache.- Returns:
- the transformed formula
-
-