Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [41]
Prior to 1938, people knew that when you wired two switches in series, both switches had to be closed for current to flow, and when you wired two switches in parallel, one or the other had to be closed. But nobody had shown with Shannon's clarity and rigor that electrical engineers could use all the tools of Boolean algebra to design circuits with switches. In particular, if you can simplify a Boolean expression that describes a network, you can simplify the network accordingly.
For example, the expression that indicates the characteristics you want in a cat looks like this:
(M x N x (W + T)) + (F x N x (1 – W)) + B
Using the associative law, we can reorder the variables that are combined with the AND (x) signs and rewrite the expression this way:
(N x M x (W + T)) + (N x F x (1 – W)) + B
In an attempt to clarify what I'm going to do here, I'll define two new symbols named X and Y:
X = M x (W + T)
Y = F x (1 – W)
Now the expression for the cat you want can be written like this:
(N x X) + (N x Y) + B
After we're finished, we can put the X and Y expressions back in.
Notice that the N variable appears twice in the expression. Using the distributive law, the expression can be rewritten like this, with only one N:
(N x (X + Y)) + B
Now let's put the X and Y expressions back in:
(N x ((M x (W + T)) + (F x (1 – W)))) + B
Due to the plethora of parentheses, this expression hardly looks simplified. But there's one less variable in this expression, which means there's one less switch in the network. Here's the revised version:
Indeed, it's probably easier to see that this network is equivalent to the earlier one than to verify that the expressions are the same.
Actually, there are still three too many switches in this network. In theory, you need only four switches to define your perfect cat. Why four? Each switch is a bit. You should be able to get by with one switch for the sex (off for male, on for female), another switch that's on for neutered, off for unneutered, and two more switches for the color. There are four possible colors (white, black, tan, and "other"), and we know that four choices can be defined with 2 bits, so all you need are two color switches. For example, both switches can be off for white, one switch on for black, the other switch on for tan, and both switches on for other colors.
Let's make a control panel right now for choosing a cat. The control panel is simply four switches (much like the on/off switches you have on your walls for controlling your lights) and a lightbulb mounted in a panel:
The switches are on (closed) when they're up, and off (open) when they're down. The two switches for the cat's color are labeled somewhat obscurely, I'm afraid, but that's a drawback of reducing this panel to the bare minimum: The left switch of the pair is labeled B; that means that the left switch on by itself (as shown) indicates the color black. The right switch of the pair is labeled T; that switch on by itself means the color tan. Both switches up means other colors; this choice is labeled O. Both switches down means the color white, indicated by W, the letter at the bottom.
In computer terminology, the switches are an input device. Input is information that controls how a circuit behaves. In this case, the input switches correspond to 4 bits of information that describe a cat. The output device is the lightbulb. This bulb lights up if the switches describe a satisfactory cat. The switches shown in the control panel on page 104 are set for a female unneutered black cat. This satisfies your criteria, so the lightbulb is lit.
Now all we have to do is design a circuit that makes this control panel work.
You'll recall that Claude Shannon's thesis was entitled "A Symbolic Analysis of Relay and Switching Circuits." The relays he was referring to were quite similar to the telegraph relays that we encountered in Chapter 6. By the time of Shannon's paper, however, relays were being used