The Logic of Boolean Algebra

The logical simplicity of boolean algebra enables the construction of powerful, efficient search queries. The concept of boolean algebra is embedded in human psychology, in our very biological understanding of how the world works. It is the foundation for all of mathematics, most of science, and much of philosophy.

But more importantly, it is useful for the construction of advanced Internet search queries, and is used throughout the examples in the following pages. The subsections below provide information on boolean expressions, the boolean operators AND, OR, and NOT, some boolean tricks, and and a list of boolean capable search sites.

Expressions. It is easier to understand boolean algebra when we compare it to the familiar arithmetic algebra we learned in school, with the operators +, –, x, / combined with operands in expressions like the following:

( a + b ) x c

When we know the values of the operands of an algebraic expression, then we can figure out the overall value. For example, if a=2, b =3, and c=4, then the overall value of the above expression is 20.

Boolean algebra is very similar, with the logical operators AND, OR, and NOT, combined with operands that can have either a value of True or False in expressions like the following:

( a AND b ) OR c

Like any algebra, if you know the rules and value of the operands, you can figure out the overall expression. In this case, if a=True, b=False, and c=True, then the overall value of the above expression is True, according to the rules described below.

AND. The most useful boolean operator is AND because it combines truth values. An expression “a AND b” is True only if both of the operands are True. For example, if a=”You are wearing glasses” and b=”You are wearing a watch”, then the overall expression is true only if you are wearing both items of clothing at the same time, and false if you are wearing only one item or neither. The rules of the AND operator are shown in the truth table below.

a AND b

b

False

True

a

False

False

False

True

False

True

AND Truth Table

Or. The expression “A or B” is true if either of the operands is true. For example, the expression “you are wearing a watch or you are wearing glasses” is true if you are wearing either item or both, and false only if you aren’t wearing either. The truth table is shown below.

a OR b

b

False

True

a

False

False

True

True

True

True

OR Truth Table

NOT. The NOT operator simply reverses the truth of whatever it operates on. For example, the expression “I am not wearing a watch” is True if you aren’t wearing a watch, and False if you are. The truth table is shown below.

a

NOT a

False

True

True

False

NOT Truth Table

Tricks. Some of the most useful boolean algebra tricks are listed below. Both sides of each listed expression are logically equivalent, but the right-hand side is in a shorter form. You can sometimes use these tricks to reorder a long search query into a more manageable form.

Long Form
Shorter Form
( a AND b ) OR ( a AND c ) =   a AND ( b OR c )
( a OR b ) AND ( a OR c ) =   a OR ( b AND c )
NOT NOT a =   a
NOT a AND NOT b =   NOT ( a OR b )
NOT a OR NOT b =   NOT ( a AND b )

Boolean sites. Boolean algebra queries are supported by most search engines, but sometimes only through the “advanced” version. Remember that the most common setting is to require boolean operators in all CAPS or they won’t be recognized, and that the NOT operator must often be written as a minus sign, as in the following Google search query:

garden AND (lettuce OR tomatoes) AND -carrots

The following site search pages provide boolean search capability: