Boolean Algebra

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Background[edit]

The branch of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0 respectively. It is a formal description of logical relations. It was introduced by George Boole in his first book The Mathematical Analysis of Logic in 1847.

Alternative names for true and false:

false true
no yes
0 1
F T

Basic Operations[edit]

  • AND, formally termed conjunction and denoted by
  • OR, formally termed disjunction and denoted by
  • NOT, formally termed negation, and denoted by

There are also several "shortcut" notations that we can use for more succinct expressions:

  • conjunction may be written as multiplication, i.e. or, more simply,
  • disjunction may be written as addition, i.e.
  • negation may be written with a bar above the variable, i.e.

Truth Tables[edit]

Truth tables provide us with a straightforward means to specify the required output(s) for the specified input(s), in table form. On the left-hand side of the table we enumerate the input(s) and on the right-hand side of the table we specify the output(s). Assuming that we have inputs we may label each input as . The value of the inputs on any given row, may be referred to as an input tuple. Likewise, assuming that we have outputs we may label each output as , and the value of these outputs on any given row may be referred to as an output tuple. The number of rows in any such table is given by the formula . When there is a single output, we can formalize the relationship as

QuestionQuestion Mark Icon - Blue Box.svg

Why is the formula for determining the number of rows in a truth table related only to the number of inputs, and why is the formula ?

Note that for convenience we sometimes label inputs as A, B, C, etc. rather than etc. and do the same for outputs, often beginning with the letter Q.

Hint.pngHelpful Hint

When writing truth tables, it is very helpful to always write them in the same order. This helps in reading and memorizing the tables because we can simply memorize the output column(s), because the input columns will always be the same. For example, consider the AND truth table:

x y
0 0 0
0 1 0
1 0 0
1 1 1

Rather than memorizing the entire table, we can just memorize the output column, i.e. 0 0 0 1. And, in most cases, we really only need to memorize the exceptional cases.


There are possible single-output Boolean functions that can be defined over inputs. These are enumerated, with explanations, in the following table.

Function Name Boolean Algebraic Formula Truth Table Explanation
x 0 0 1 1
y 0 1 0 1
Constant 0 0 0 0 0 0 Always false
AND 0 0 0 1 x and y are true
AND NOT 0 0 1 0 x is true and y is false
0 0 1 1 x is true, y is irrelevant
NOT AND 0 1 0 0 x is false and y is true
0 1 0 1 y is true, x is irrelevant
XOR 0 1 1 0 x is true or y is true but both are not true
x is different than y
OR 0 1 1 1 Either x or y is true
NOR 1 0 0 0 Neither x nor y is true
EQUIVALENCE 1 0 0 1 x is the same as y
NOT 1 0 1 0 y is false, x is irrelevant
IMPLYs 1 0 1 1 x is true or y is false
NOT 1 1 0 0 x is false, y is irrelevant
IMPLYs 1 1 0 1 y is true or x is false
NAND 1 1 1 0 x and y are not both true
Constant 1 1 1 1 1 1 Always true

Logic Gates[edit]

An idealized or physical device implementing a Boolean function; that is, it performs a logical operation on one or more binary inputs and produces one or more binary outputs. The table below provides the symbols that are used to represent common gates.

Formal Name Abbreviated Name Symbol Gate Truth Table
Buffer Gate Buffer.png
Inputs Outputs
0 0
1 1
Conjunction AND Gate AND.png
Inputs Outputs
0 0 0
0 1 0
1 0 0
1 1 1
Disjunction OR Gate OR.png
Inputs Outputs
0 0 0
0 1 1
1 0 1
1 1 1
Exclusive OR XOR Gate XOR.png
Inputs Outputs
0 0 0
0 1 1
1 0 1
1 1 0
Inverter NOT Gate Inverter.png
Inputs Outputs
0 1
1 0
Negated Conjunction NAND Gate NAND.png
Inputs Outputs
0 0 1
0 1 1
1 0 1
1 1 0
Negated Disjunction NOR Gate NOR.png
Inputs Outputs
0 0 1
0 1 0
1 0 0
1 1 0
Negated Exclusive OR NOT XOR Gate NOT XOR.png
Inputs Outputs
0 0 1
0 1 0
1 0 0
1 1 1

De Morgan's Laws[edit]

De Morgan's Laws provide a helpful formula to obtain the same truth table of:

  • an AND gate by using negation and an OR gate, or
  • an OR gate by using negation and an AND gate

The Laws are:

References[edit]