public BooleanFormula andWith ( BooleanFormula other ) { if ( other . isTrue ( ) ) { return this ; } if ( other . isFalse ( ) || isFalse ( ) ) { if ( booleanTerms == null ) { booleanTerms = new HashSet < BooleanTerm > ( ) ; } else { booleanTerms . clear ( ) ; } isSimplified = true ; return this ; } if ( isTrue ( ) ) { booleanTerms = new HashSet < BooleanTerm > ( other . booleanTerms ) ; return this ; } BooleanFormula newTerms = new BooleanFormula ( ) ; for ( BooleanTerm otherTerm : other ) { for ( BooleanTerm term : booleanTerms ) { BooleanTerm newTerm = term . andWith ( otherTerm ) ; if ( newTerm != null ) { newTerms . add ( newTerm ) ; } } } booleanTerms = newTerms . booleanTerms ; isSimplified = newTerms . isSimplified ; return this ; }
Logically ands the provided terms with the terms in the formula replacing this formula with the result