Module logicng

Class BinaryOperator

    • Field Detail

      • left

        protected final Formula left
      • right

        protected final Formula right
      • hashCode

        protected volatile int hashCode
    • Method Detail

      • left

        public Formula left()
        Returns the left-hand side operator.
        Returns:
        the left-hand side operator
      • right

        public Formula right()
        Returns the right-hand side operator.
        Returns:
        the right-hand side operator
      • numberOfOperands

        public int numberOfOperands()
        Description copied from class: Formula
        Returns the number of operands of this formula.
        Specified by:
        numberOfOperands in class Formula
        Returns:
        the number of operands of this formula
      • isConstantFormula

        public boolean isConstantFormula()
        Description copied from class: Formula
        Returns whether this formula is a constant formula ("True" or "False").
        Specified by:
        isConstantFormula in class Formula
        Returns:
        true if this formula is a constant formula, false otherwise
      • isAtomicFormula

        public boolean isAtomicFormula()
        Description copied from class: Formula
        Returns whether this formula is an atomic formula (constant, literal, pseudo Boolean constraint), or not.
        Specified by:
        isAtomicFormula in class Formula
        Returns:
        true if this formula is an atomic formula, false otherwise
      • containsVariable

        public boolean containsVariable​(Variable variable)
        Description copied from class: Formula
        Returns true if a given variable name is found in this formula, false otherwise.
        Specified by:
        containsVariable in class Formula
        Parameters:
        variable - the variable to search for
        Returns:
        true if a given variable is found in this formula
      • containsNode

        public boolean containsNode​(Formula formula)
        Description copied from class: Formula
        Returns true if this formula contains a given node, false otherwise.

        In particular, a Literal node ~a does NOT contain the node a.

        Specified by:
        containsNode in class Formula
        Parameters:
        formula - the node
        Returns:
        true if this formula contains a given node
      • substitute

        public Formula substitute​(Substitution substitution)
        Description copied from class: Formula
        Performs a given substitution on this formula.
        Specified by:
        substitute in class Formula
        Parameters:
        substitution - the substitution
        Returns:
        a new substituted formula
      • negate

        public Formula negate()
        Description copied from class: Formula
        Returns a negated copy of this formula.
        Specified by:
        negate in class Formula
        Returns:
        a negated copy of this formula
      • stream

        public Stream<Formula> stream()
        Description copied from class: Formula
        Returns 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.

        Specified by:
        stream in class Formula
        Returns:
        the stream