15th of March, 2026

Basic Logic

If you thought the previous chapter was abstract, you’re going to love this one. Bear with me as I explain some of these foundational things as they will make everything which follows much easier to understand. The next chapter will show us how these abstract concepts are used in the real-world (in hardware/physical constructions).

Computers use electrical signals to perform computations. These electrical signals can be either on or off. The binary system we saw in the previous chapters maps to this system of electrical signals. Another way to view these signals is as boolean (or truth) values. When electrical current is flowing and the signal is on, we can view as the true state. The opposite case, when there is no electrical current and the signal is off can be seen as a false state. All operations a computer performs can be mapped down to boolean logic. Logic which uses exclusively true and false values.

The Three Basic Operations

Boolean logic uses three basic operations. These operations are AND, OR and NOT. The AND operation takes two values, \(x\) and \(y\), and returns true if both \(x\) and \(y\) are true. If either or both values are false, the operation return false. Explaining this in text can be confusing and complex, and this is where truth tables can help us. These tables show the input values for a given operation, across all possible state combinations, with the resulting outcome. Let’s take a look at the truth table for the AND operation:

\(x\) \(y\) Result
0 0 0
1 0 0
0 1 0
1 1 1

This table shows us that the AND operation will only return true (denoted by 1) if both input values are true. The OR operation will return true if either or both of the input values are true. This results in the following truth table:

\(x\) \(y\) Result
0 0 0
1 0 1
0 1 1
1 1 1

Finally, the NOT operation flips the value of its input. If you give it a true value, it will return false, and vice-versa. This is reflected in its truth table:

\(x\) Result
0 1
1 0

More Complex Operations

The three basic operations together are functionally complete. This means that using these three operations we can create any other logical operation. This section will cover one such operation, the XOR (exclusive OR). This operation returns true only if exclusively one of the input values is true. If both values are true the XOR will return false. How would you construct this operation using the three operations above? Take a second to think.

We can use the following combination of all three operations to construct the XOR: (\(x\) AND NOT \(y\)) OR (\(y\) AND NOT \(x\))

Now, you might be thinking, what do I do with this knowledge (as I was during my university class on logic)? How is this boolean logic relevant for computers and whatever my partner does at work? Let me explain. Logical operations can be used to perform any operation we want. In the realm of computers everything is a logical operation (as it is just 1’s and 0’s, true and false). As an example, let’s sum two numbers using logical operations!