- java.lang.Object
-
- org.logicng.formulas.Formula
-
- org.logicng.formulas.Constant
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsNode(Formula formula)Returnstrueif this formula contains a given node,falseotherwise.booleancontainsVariable(Variable variable)Returnstrueif a given variable name is found in this formula,falseotherwise.booleanisAtomicFormula()Returns whether this formula is an atomic formula (constant, literal, pseudo Boolean constraint), or not.booleanisConstantFormula()Returns whether this formula is a constant formula ("True" or "False").Iterator<Formula>iterator()intnumberOfOperands()Returns the number of operands of this formula.Formularestrict(Assignment assignment)Restricts this formula with a given assignment.Stream<Formula>stream()Returns a stream of this formula's operands.Formulasubstitute(Substitution substitution)Performs a given substitution on this formula.-
Methods inherited from class org.logicng.formulas.Formula
apply, apply, bdd, bdd, clearCaches, cnf, containsVariable, evaluate, factory, functionCacheEntry, holds, holds, implies, isCNF, isContradiction, isDNF, isEquivalentTo, isImpliedBy, isNNF, isSatisfiable, isTautology, literals, negate, nnf, numberOfAtoms, numberOfInternalNodes, numberOfNodes, predicateCacheEntry, setFunctionCacheEntry, setPredicateCacheEntry, setPredicateCacheEntry, setTransformationCacheEntry, substitute, toString, transform, transform, transformationCacheEntry, type, variables
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
numberOfOperands
public int numberOfOperands()
Description copied from class:FormulaReturns the number of operands of this formula.- Specified by:
numberOfOperandsin classFormula- Returns:
- the number of operands of this formula
-
isConstantFormula
public boolean isConstantFormula()
Description copied from class:FormulaReturns whether this formula is a constant formula ("True" or "False").- Specified by:
isConstantFormulain classFormula- Returns:
trueif this formula is a constant formula,falseotherwise
-
isAtomicFormula
public boolean isAtomicFormula()
Description copied from class:FormulaReturns whether this formula is an atomic formula (constant, literal, pseudo Boolean constraint), or not.- Specified by:
isAtomicFormulain classFormula- Returns:
trueif this formula is an atomic formula,falseotherwise
-
containsVariable
public boolean containsVariable(Variable variable)
Description copied from class:FormulaReturnstrueif a given variable name is found in this formula,falseotherwise.- Specified by:
containsVariablein classFormula- Parameters:
variable- the variable to search for- Returns:
trueif a given variable is found in this formula
-
restrict
public Formula restrict(Assignment assignment)
Description copied from class:FormulaRestricts this formula with a given assignment.
-
containsNode
public boolean containsNode(Formula formula)
Description copied from class:FormulaReturnstrueif this formula contains a given node,falseotherwise.In particular, a
Literalnode~adoes NOT contain the nodea.- Specified by:
containsNodein classFormula- Parameters:
formula- the node- Returns:
trueif this formula contains a given node
-
substitute
public Formula substitute(Substitution substitution)
Description copied from class:FormulaPerforms a given substitution on this formula.- Specified by:
substitutein classFormula- Parameters:
substitution- the substitution- Returns:
- a new substituted formula
-
stream
public Stream<Formula> stream()
Description copied from class:FormulaReturns a stream of this formula's operands.Most times streams have worse performance then iterating over the formula per iterator. Since internally formulas store their operands, a costly call to
Arrays.stream()is necessary. So if performance matters - avoid using streams.
-
-