Introduction to Boolean Logic
Written by Mike James   
Tuesday, 11 March 2025
Article Index
Introduction to Boolean Logic
Truth Tables
Binary arithmetic and flip-flops
Binary arithmetic
Flip Flops - Time Enters the Logic
De Morgan's Laws
Logic, Finite State Machines and Computers

Truth Tables

The rules for combining expressions are usually written down as tables listing all of the possible outcomes. These are called truth tables and for the three fundamental operators these are:

 

P Q P AND Q
F F F
F T F
T F F
T T T

 

P Q P OR Q
F F F
F T T
T F T
T T T

 

P NOT P
F T
T F

Notice that while the Boolean AND is the same as the English use of the term, the Boolean OR is a little different. When you are asked would you like tea OR coffee you are not expected to say yes to both! In the Boolean case, however, “OR” most certainly includes both. When P is true and Q is true the combined expression (P OR Q) is also true.

There is a Boolean operator that corresponds to the English use of the term “or” and it is called the “Exclusive OR” written as XOR or EOR. Its truth table is: 

P Q P XOR Q
F F F
F T T
T F T
T T F

 

and this one really would stop you having both the tea and the coffee at the same time (notice the last line is True XOR True = False).

Practical truth tables

All this seems very easy but what value does it have? It most certainly isn’t a model for everyday reasoning except at the most trivial “tea or coffee” level. We do use Boolean logic in our thinking, but only at the most trivially obvious level. However, if you start to design machines that have to respond to the outside world in even a reasonably complex way then you quickly discover that Boolean logic is a great help.

For example, suppose you want to build a security system which only works at night and responds to a door being opened. If you have a light sensor you can treat this as giving off a signal that indicates the truth of the statement:

P = It is daytime.

Clearly NOT(P) is true at night and we have our first practical use for Boolean logic! Similarly the door opening sensor can be considered to correspond to true if the door is open:

Q = door open

What we really want is something that works out the truth of the statement:

R = burglary in progress 

in terms of P and Q.

A little thought soon leads to the solution:

R = NOT(P) AND Q

 

That is, the truth of “burglary in progress” is given by:

 

P Q NOT(P) NOT(P)AND Q
F F T F
F T T T
T F F F
T T F F

 

From this you should be able to see that the alarm only goes off when it is night-time and a window opens.

Banner



Last Updated ( Tuesday, 11 March 2025 )