Booleans

The Booleans are about the simplest set of numbers you could reasonably want to use: zero and one. They are named in honor of George Boole, who was born the same year as Ada Lovelace and is most famous for publishing The Laws of Thought, on the subject of what would become known as Boolean algebra. Since nearly all modern computer hardware is binary, the study of Booleans is essential to understanding low-level hardware capabilities and efficiency.

The main operations on Booleans are AND, OR, and NOT, with equality and difference also implicitly crucial. Although they are conventionally written in uppercase to avoid confusion with the English conjunctions ‘and’, ‘or’, and ‘not’, the operators are intended as mathematical distillations of the ideas of those conjunctions.

The AND operator is a binary operator, not in the sense of zero/one but in the sense of taking two operands, like multiplication. The result of AND is true if its left operand is true and its right operand is true, and otherwise the result is false. This can be expressed in a table, called a truth table, showing all possible combinations of inputs and the result for each.

Truth table for AND

A

B

A AND B

0

0

0

0

1

0

1

0

0

1

1

1

The OR operator is also a binary Boolean operator, taking two Boolean inputs and producing a Boolean result, but in this case the result is true if the left operand is true or the right operand is true (or both).

Truth table for OR

A

B

A OR B

0

0

0

0

1

1

1

0

1

1

1

1

The NOT operator is a unary operator, meaning it takes only one operand as input; the result is the opposite of the input.

Truth table for NOT

A

NOT A

0

1

1

0

Since whether two things are equal is essentially a Boolean question—they are or they are not, true or false—equality always produces a Boolean result, even when the things you are testing for equality are of other types. But when the inputs are themselves Boolean, equality is clearly a binary operator. Inequality, or difference, its negation, is equally important.

Truth tables for = and ≠

A

B

A = B

A ≠ B

0

0

1

0

0

1

0

1

1

0

0

1

1

1

1

0

In logic, particularly as a branch of philosophy, the two Boolean values are called ‘false’ and ‘true’ more commonly than 0 and 1 respectively, but thinking of them as numbers both makes for shorter, clearer writing, and also invites a connection to operators on numbers generally. In particular, consider this excerpted ‘times table’.

Excerpted times table

A

B

A × B

0

0

0

0

1

0

1

0

0

1

1

1

Of course, the actual table for multiplication of natural numbers would be infinite, but this part should seem familiar…it’s AND! Okay, so what about a table for addition? Let’s write it in base 2 so we can see the Boolean connection a little easier.

Excerpted plus table

A

B

A + B

0

0

0

0

1

1

1

0

1

1

1

10

Right up until things got weird, that seemed to be OR. The issue is that one plus one equals two, and two, or 10 in binary, isn’t just one Boolean result, so to squeeze addition into the role of a Boolean operator, we’d have to pick. If we pick the 1, then indeed addition is just OR.

If we pick the 0 instead, we get this truth table, which actually corresponds to another way people sometimes use ‘or’ in English.

Truth table for exclusive OR

A

B

A XOR B

0

0

0

0

1

1

1

0

1

1

1

0

Where the usual logical sense of OR is ‘one or the other or both’, which is called ‘inclusive’ OR, this is the ‘exclusive’ OR, meaning ‘one or the other but not both’. The exclusive OR is commonly abbreviated XOR, but if you look closely, you’ll see it’s also exactly the same as not-equal. Thinking of this as XOR makes sense in some contexts, and thinking of it as different or not-equal makes sense in some contexts. (On the other hand, getting too caught up thinking of it as XOR has led some people to define its negation as ‘not-exclusive-or’ abbreviated ‘NXOR’ rather than just ‘equals’!)

You have attempted of activities on this page