- java.lang.Object
-
- org.logicng.datastructures.Substitution
-
public final class Substitution extends Object
A Boolean substitution.- Since:
- 1.0
- Version:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description Substitution()Constructs a new empty substitution.Substitution(Map<Variable,Formula> mapping)Constructs a new substitution and initializes it with the given mapping.Substitution(Substitution other)Constructs a new substitution by copying the given one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapping(Variable variable, Formula formula)Adds a mapping from variable to formula to this substitution.booleanequals(Object other)Map<Variable,Formula>getMapping()Returns an unmodifiable reference to the internal mapping of variables to formulas.FormulagetSubstitution(Variable variable)Returns a formula for a given variable.inthashCode()intsize()Returns the number of mappings in this substitution.StringtoString()
-
-
-
Constructor Detail
-
Substitution
public Substitution()
Constructs a new empty substitution.
-
Substitution
public Substitution(Substitution other)
Constructs a new substitution by copying the given one.- Parameters:
other- the substitution to copy
-
-
Method Detail
-
size
public int size()
Returns the number of mappings in this substitution.- Returns:
- the number of mappings in this substitution
-
addMapping
public void addMapping(Variable variable, Formula formula)
Adds a mapping from variable to formula to this substitution.If there is already a mapping for this variable, it will be overwritten.
- Parameters:
variable- the variableformula- the formula
-
getSubstitution
public Formula getSubstitution(Variable variable)
Returns a formula for a given variable. If there is no mapping for this variable,nullis returned.- Parameters:
variable- the variable- Returns:
- a formula or
null
-
getMapping
public Map<Variable,Formula> getMapping()
Returns an unmodifiable reference to the internal mapping of variables to formulas.- Returns:
- the internal mapping of variables to formulas
-
-