Practical uses of Boolean logic

This chapter will introduce three very practical uses of Boolean logic:

Boolean logic as a model for digital computer circuits

Boolean logic was recognized early as a useful system in to produce mathematical models of computer systems. In this section we will give a glimpse of what this means. We will not spend much time describing how an engineer systematically designs a computer circuit; instead we will discuss the devices she uses to compose a circuit, how those devices are modeled by Boolean logic, and show an example of a very useful circuit made up of these devices.

Digital circuitry usually works with two electrical signals distinguished by their voltages. For example a digital circuit might work with signals of +5 volts and 0 volts. With only two types of signals to deal with, it is natural to ask if Boolean logic might be used to model these signals. The answer, of course, is yes. So let us choose T to represent +5 volts and F to represent 0 volts. Since these Boolean literals are abstract, we are perfectly justified in making this assignment of meaning to voltages in the real world.

For reference, we repeat the figure that shows the axioms of Boolean logic that we have discussed.

Inverter gate

Select the Negation tab. Now imagine that the T and F literals are replaced with +5 and 0. The negation operator can now be imagined to be implemented by an electrical device which has an electrical input terminal and an electrical output terminal. If the input terminal is connected to a source of 0 volts, then the output terminal should show a voltage of +5 volts.

Now look at the following figure.

What is shown is a simple electronic circuit diagram composed of a switch, labeled S1, a digital device, labeled N1 and an indicator light, labeled I1.

The switch, in the down position, is connected to 0 volts, which is indicated by the ground symbol. In the up position, it is connected to +5 volts. The output voltage of the switch is determined by whether its position is up or down. You can change the position of the switch by moving the mouse cursor over the switch and clicking the left mouse button.

The colored lines represent wires. The voltage on each wire is depicted by its color: red for 0 volts and green for +5 volts. Notice that when you change the position of the switch, its output wire changes color.

The digital device has one input terminal which is connected to the switch. Its output terminal is connected to a wire that is exactly the opposite color as its input wire. Why is the digital device illustrated as a triangle with a little circle on its apex? We won't get into that right now, so just accept that it is for arbitrary historical reasons.

Because computers are supposed to have flashing lights, the output of the digital device is connected to an indicator lamp which lights up according to the voltage it receives from the digital device.

Now we claim that the behavior of the digital device shown is modeled by the axioms of Boolean negation . The triangular symbol in the circuit diagram is called an inverter gate or simply an inverter.

Stretch your mind

  • Recall that there are three other Boolean unary operators besides Boolean negation. Can you produce a circuit diagram for each of these?
  • And gate

    Now select the And tab from the Boolean logic figure above. Again, we will interpret T as +5 volts and F as 0 volts.

    Look at the next figure which shows, similar to the inverter, a device with two input ports, each connected to a separate switch.

    By manipulating the two switches and observing the state of the indicator lamp, you will see that the behavior of the electrical device is modeled by the Boolean and operator. The electrical device is called an And gate.

    Or gate

    Now select the Or tab from the Boolean logic figure above.

    The next figure shows a device with two input ports, each connected to a separate switch.

    By manipulating the two switches and observing the state of the indicator lamp, you will see that the behavior of the electrical device is modeled by the Boolean or operator. The electrical device is called an Or gate.

    Exclusive or gate

    Now select the Exclusive or tab from the Boolean logic figure above.

    The next figure shows a device with two input ports, each connected to a separate switch.

    By manipulating the two switches and observing the state of the indicator lamp, you will see that the behavior of the electrical device is modeled by the Boolean exclusive or operator. The electrical device is called an Exclusive or gate.

    There are other types of gates common in computer circuit design. Some of these gates are modeled by some of the other sixteen binary Boolean operators. Because this section is not intended to be a lesson on computer circuit design, we will not discuss them.

    Two bit adder

    We have shown a set of electrical devices that are modeled by a subset of Boolean logic. We will now show how these devices can be connected in ways to perform useful computations in a computer.

    The figure above will touch on a subject called binary arithmetic which we have not discussed yet. You may already know about binary arithmetic, but if you don't, we will try to explain enough so you can see what the circuit in the figure does.

    The circuit adds two numbers, each in the range of 0 through 3 to produce a sum in the range of 0 through 6. (You may say "Well, that's not very useful because I don't need a computer to do that sort of problem." You are right, but the circuit can be easily extended to add very large numbers very quickly, which we do need computers to do.)

    How do we tell the circuit what numbers to add? Notice that there are two sets of two switches on the left of the figure: P0, P1, Q0 and Q1.

    The switches P0 and P1 are used to encode a number between 0 and 3 as follows: If a switch is down assign it a value of 0 and if it is up assign it a value of 1. The number encoded is value of P0 plus 2 times the value of P1. Verify for yourself that you can encode the numbers 0, 1, 2 and 3. The switches Q0 and Q1 similarly encode the other number to be added.

    The sum of the two numbers are displayed in the three indicator lamps S0, S1 and S2. Assign each lamp the value 0 if it is off (red) and the value 1 if it is on (green). The encoded computed sum is the value of S0 plus 2 times the value of S1 plus 4 times the value of S2.

    You should verify with a couple of examples that the adder actually works as advertised.

    You might ask "Isn't this awfully complicated to just add two numbers?" While the circuit may look complicated, it is really very simple and it is practical because the electrical devices that it uses are small, cheap, easy to replicate, and do their job very fast. The computer you are using to read this is proof that the concept is practical.

    Boolean logic in mathematical proofs

    Under construction

    Boolean logic in computer programming languages

    Under construction

    Next section: Limitations of Boolean logic