Boolean (logical) constants and operators make it possible to logically combine relations and/or truth-valued variables into Boolean expressions.  For functions that perform operations on Boolean expressions (such as putting them in normal form) see the Boolean FunctionsBoolean_Functions.


The Boolean truth value constants are denoted by true and false.  The following are the Boolean operators:

       NOT p (displayed as ¬p) is the negation of p.  NOT is a unary prefix Boolean operator.  If p is true, NOT p simplifies to false.  If p is false, NOT p simplifies to true.  For example, NOT x>5 is true if x is not greater than 5 (i.e. if x is less than or equal to 5).

       p AND q (displayed as p q) is the conjunction of p and q.  AND is a binary infix Boolean operator.  If both p and q are true, p AND q simplifies to true.  If either p or q or both are false, p AND q simplifies to false.  For example, x<3 AND y=7 is true if both x is less than 3 and y is 7.

       p OR q (displayed as p q) is the disjunction (inclusive or) of p and q.  OR is a binary infix Boolean operator.  If either p or q or both are true, p OR q simplifies to true.  If both p and q are false, p OR q simplifies to false.  For example, x<3 OR y=7 is true if either x is less than 3 or y is 7 or both are true.

       p XOR q (displayed as p q) is the exclusive or of p and q.  XOR is a binary infix Boolean operator.  If either p or q but not both are true, p XOR q simplifies to true.  If both p and q are false or if both p and q are true, p XOR q simplifies to false.  If the truth values of p and q are unknown, p XOR q simplifies to the equivalent Boolean expression (NOT p AND q) OR (p AND NOT q).

       p IMP q (displayed as p q) is a conditional (implication) with antecedent p and consequent q.  IMP is a binary infix Boolean operator.  If p is false or q is true, p IMP q simplifies to true.  If p is true and q is false, p IMP q simplifies to false.  If the truth values of p and q are unknown, p IMP q simplifies to the equivalent Boolean expression NOT p OR q.

       p IFF q (displayed as p q) is the logical equivalence of p and q.  IFF (if-and-only-if) is a binary infix Boolean operator.   If both p and q are true or if both p and q are false, p IFF q simplifies to true.   If p is true and q is false or if p is false and q is true, p IFF q simplifies to false.  If the truth values of p and q are unknown, p IFF q simplifies to the equivalent Boolean expression (¬ p OR q) AND (p OR ¬ q).


As with the Numerical OperatorsNumerical_Operators, you can use parentheses to control the order in which Boolean operators are applied.  In the absence of parentheses, Boolean operators with higher precedence are applied before those with lower precedence.  The Boolean operators above are listed in order of decreasing precedence.  For example, entering

NOT p OR q AND r

is equivalent to entering

(NOT p) OR (q AND r)


Expressions involving Boolean operators may have many logically equivalent forms.  Derive uses the laws of Boolean algebra to simplify Boolean expressions into simpler ones having the same truth value.  The following identities, valid for any truth values p, q, and r, are among those used to simplify expressions involving AND and OR:

p AND q  ⇐⇒  q AND p

p OR q  ⇐⇒  q OR p

p AND (q AND r)  ⇐⇒  (p AND q) AND r

p OR (q OR r)  ⇐⇒  (p OR q) OR r

p AND q OR p AND r  ⇐⇒  p AND (q OR r)

(p OR q) AND (p OR r)  ⇐⇒  p OR q AND r


The first two identities indicate that AND and OR are commutative.  The second two indicate that AND and OR are associative.  The last two indicate that AND distributes over OR and that OR distributes over AND.  To simplify Boolean expressions, Derive applies the last two identities in the left-to-right direction.  For example,

(x>0 AND y=3) OR (x>0 AND z=5)

simplifies to

(y = 3 z = 5) x > 0

and

p AND ((p AND q) OR r)

simplifies to

p (q r)


The following transformations are among those used to simplify Boolean expressions involving NOT:

p OR NOT p true

p AND NOT p false

NOT NOT p    p

NOT (p AND q)    NOT p  OR  NOT q

NOT (p OR q)    NOT p  AND NOT q


The last two identities, called De Morgan's laws, allow NOT to be distributed over conjunctions and disjunctions.  To simplify Boolean expressions, Derive repeatedly applies the above rules to force the NOT operator to the lowest level.


Relations combined by Boolean operators are also simplified when possible.  For example,

6 >= -2·x AND 3·x /= -9

simplifies to

x > -3


When given integer operands, the Boolean (logical) operators perform bit-wise logical operations on the integers.  The operations are performed as if integers are stored using a "half-infinite" two's-complement representation.  For example,

3 OR 5

simplifies to 7, and

NOT 5

simplifies to -6.


Other Built-in Functions and ConstantsBuilt_in_Functions_and_Constants 

Created with the Personal Edition of HelpNDoc: Full-featured EPub generator