Boolean Logic [From the Archives]

My “Day I Left Pennsylvania” led me to some archived website posts (before blogs were invented) I had written many years ago. I’m re-posting them now. Bear in mind that most of the content in this series is over 5 years old. I have left the content more or less intact. I have removed some links and added some others — but that’s it. Enjoy!

This post contains egregious use of math, and may be unsuitable for Liberal Arts majors. Caveat lector.


Boolean Logic is based on the idea that we can define truths based on simple black & white statements; All of which have a simple “True” or “False” answer. A few terms you should familiarize yourself with before we begin are:

Binary Values

Binary, or base 2, is a counting system where the only numbers used are 1 and 0. Most people are at least acquainted with this idea, since it’s the backbone of modern computing.

1TrueOnYes

All of these values are considered equal. (as an aside, in computer programming, any non-zero value is considered “true” while the only value that is false is zero itself)

0FalseOffNo

All of these values are considered equal also, one and the same. In some cases we will use 0, in others “False” (or simply “F”), with computing it is “off”.

Binary Operations

In mathematics and regular arithematic you have addition ( + ), subtraction ( – ), multiplication ( x ) and division ( / ), as well as some others. In Boolean arithemetic our operations are slightly different: We have AND ( x ), OR ( + ), NOT ( ! ), and some others.

Truth Tables

A truth table is a small T-table set up for a boolean equation or statement. One one side you can either have an expression or a test value, and on the other you have the the value of that expression or the “output”, respectively. These are crucial in Boolean logic.

Sample Truth Table

Primary Colors that make Green
Test Value
Output
Red
False
Blue
True
Yellow
True

In this particular table, the expression is “Primary Colors that make Green”. We will be testing the colors in the first column to see if they are part of the makeup of the pigment color Green. The right column is the result of each individual test value. The first row has “Red”. We all know there is no Red in a basic Green color, so that result is “False”. The second row is “Blue”, since Green is a combination of Blue and Yellow, this result is “True”. The same thing goes for the third row, Yellow. Understand?

Boolean Operations

AND (or simply ” * “)

x AND y
x
y
Output
T
T
T
T
F
F
F
T
F
F
F
F

Syntax: x AND y. The requirement for AND is that both values be true; If both values are true, then the result is true. If either (or both) value is false, then the result is false. When x AND y are both True, as on line 1, the output is also True. Any other time it is false. You could say AND will help you find pure truth in expressions, that is, an expression totally untainted by any false values.

OR (or simply ” + “)

x OR y
x
y
Output
T
T
T
T
F
T
F
T
T
F
F
F

Syntax: x OR y. The requirement for OR is that either value be true; If either value is true, then the result is true. Both values must be false in order for the answer to be false. Simply comparing AND and OR so far, you can see that the results are inversely related. AND is far more picky than OR. However, OR can help you find pure fallacy in an expression, if the result is False, then you know every piece of the equation is false.

NOT (or simply ” ! “)

!x
x
Output
T
F
F
T

Syntax !x. NOT is more or less used to immediately invert the value, regardless of what it is. You can invert an entire expression by putting it in parentheses and placing a NOT in front of it. Think of this in the way that you would use a “-” in multiplication. You have to distribute the negative sign to all values in the parentheses, right? so -(2 + x) becomes (-2 – x).

XOR (or simply ” (+) “)

x XOR y
x
y
Output
T
T
F
T
F
T
F
T
T
F
F
F

Syntax: x XOR y. XOR is short for “Exclusive OR”. It’s values are only true in situations where the values are different. It is similar to the modulous function in arithemetic. (8 % 4 = 0, 8 % 3 = 2) The modulous function gives you the remainder of the modulants. It is commonly used to determine divisibility. A 0-value from a modulous operation means that the first term is divisible by the second. Any non-zero value is simply the remainder. XOR is commonly used to combine two strings of binary numbers. For example: 1001 XOR 1101 = 1101. If you had a longer string, such as 10010101001 XOR 10010101011, it would equal 10010101011. That would be used mostly by programmers when using a “flag” system, but we won’t get into that here.

Combining Functions

Now that we’ve covered the basic boolean functions, let’s see how they interact:

(x OR y) AND z

(x + y) * z
x
y
(x+y)
z
Output
T
T
T
T
T
T
F
T
T
T
F
T
T
T
T
F
F
F
T
F
T
T
T
F
F
T
F
T
F
F
F
T
T
F
F
F
F
F
F
F

Here we are combining the use of OR and AND. Note the use of the parentheses. We create a separate column for the resolution of the parenthetical expression first. Think of it kind of like the subtotal on a receipt. Since it’s that parenthetical expression that’s being compared against z, it makes it a little more clear to evaluate it first. We also want to compare every instance of (x+y) versus both T and F values for z.

(x AND y) OR z

(x * y) + z
x
y
(x*y)
z
Output
T
T
T
T
T
T
F
F
T
T
F
T
F
T
T
F
F
F
T
T
T
T
T
F
T
T
F
F
F
F
F
T
F
F
F
F
F
F
F
F

This equation is nearly the same as the last, except we swapped the AND and OR operations. I wanted to illustrate how it would impact the expression as a whole. Again, here we make a separate column to evaluate (x*y) before comparing it against z.

(x AND y) XOR z

(x * y) (+) z
x
y
(x*y)
z
Output
T
T
T
T
F
T
F
F
T
T
F
T
F
T
T
F
F
F
T
T
T
T
T
F
T
T
F
F
F
F
F
T
F
F
F
F
F
F
F
F

Using the XOR in place of the OR makes little impact other than causing us to have one more F.

(x OR y) XOR z

(x + y) (+) z
x
y
(x+y)
z
Output
T
T
T
T
F
T
F
T
T
F
F
T
T
T
F
F
F
F
T
T
T
T
T
F
T
T
F
T
F
T
F
T
T
F
T
F
F
F
F
F

This gives us the same number of T’s and F’s as the last time, except most have changed places.

(x XOR y) XOR z

(x (+) y) (+) z
x
y
(x(+)y)
z
Output
T
T
F
T
T
T
F
T
T
F
F
T
T
T
F
F
F
F
T
T
T
T
F
F
F
T
F
T
F
T
F
T
T
F
T
F
F
F
F
F

In this instance, we are double XORing.