next up previous contents
Next: Conditional operators (``if'', ``case'' Up: Expressions Previous: Symbolic constants   Contents

Boolean operators

The boolean operators are ``&'', for logical and, ``|'' for logical or, ``~'' for logical not, ``^'' for exclusive or , ``->'' for implies, and ``<->'' for if-and-only-if (exclusive nor). The boolean values are 0 (false) and 1 (true).

The ``&'' operator obeys the following laws:

        x & 0 = 0
        0 & x = 0
        x & 1 = 1
        1 & x = x

If neither x nor y is a boolean value, then ``x & y'' is undefined. (recall that an ``undefined'' expression yields the set of all possible values, which in the case of a boolean expression is {0,1}). In particular,

        1 & undefined = undefined
        0 & undefined = 0

That is, ``undefined'' values behave like ``X'' values in typical logic simulators. You can write an undefined value as simply {0,1}.

Also note that

        1 & 37 = 37
        0 & 37 = 0
        37 & 37 = undefined

The other boolean operators behave similarly, obeying:

        0 | x = x
        x | 0 = x
        1 | x = 1
        x | 1 = 1

        0 ^ x = x
        x ^ 0 = x
        1 ^ x = ~x
        x ^ 1 = ~x

        x -> y = ~x | y
        x <-> y = ~(x ^ y)



2002-10-28