Skip to content
LearnTronics menu

LearnTronics

AND, OR, NOT — Logic in Ordinary Language

Tutorial Index

Four little words do a lot of work

Much of digital logic grows from a few ideas we already use in speech: AND, OR, NOT, and the special “one but not both” form called XOR.

AND both must be true OR either or both XOR one, but not both NOT reverse the truth “Joe got gas AND a meal.” “Joe got gas OR a meal.” “Turn left XOR right.”

AND

“The motor may run when the guard is closed AND the start command is present.” Both conditions must be true.

ABA AND B
FFF
FTF
TFF
TTT

OR — the word that causes trouble

In everyday English, “or” can mean two different things.

“Joe stopped for gas or a meal” may still be true if Joe did both. That is inclusive OR.

“Turn left or right” usually means one direction but not both. That is exclusive OR, written XOR.

ABA OR B
FFF
FTT
TFT
TTT
ABA XOR B
FFF
FTT
TFT
TTF

NOT

NOT simply reverses a truth value. If A means “the door is open,” then NOT A means “the door is not open.”

ANOT A
FT
TF

Some terminology

AND is called conjunction. OR is disjunction. XOR is exclusive disjunction. NOT is negation. Collectively we can simply call them logical operators or connectives.

Truth tables

The small tables above are examples of a truth table. A truth table lists every possible combination of truth values for its input statements, then shows the resulting truth value of an expression for each combination.

Truth tables are useful because they replace guesswork with a complete check. Instead of asking whether a logical expression seems right, we can test every possible input case.

Important distinction: with two variables there are only 4 possible input combinations, but there are 16 different possible two-variable Boolean functions. The four input rows are fixed; what changes from one function to another is the four-value output pattern.

How to construct a truth table

1. Count the independent variables.
If there are n variables, the complete truth table needs 2n input rows.
2. Write every input combination once.
For two variables, A and B, the four combinations are FF, FT, TF, and TT. For three variables there are 8 combinations. Four variables require 16 rows.
3. Break a complex expression into smaller pieces.
Give each intermediate operation its own column. Work from the innermost or simplest operation outward.
4. Fill the final output column last.
Once all intermediate columns are complete, the final column describes the whole logical expression.
VariablesNumber of input rows
12
24
38
416
532

The number of rows doubles each time another independent variable is added because every existing combination must be considered once with the new variable false and once with it true.

Two variables can describe 16 different functions

For A and B, the input order below is always:

FF   |   FT   |   TF   |   TT

Each possible function assigns either F or T to each of those four rows. Four output positions, each with two choices, gives 24 = 16 possible output patterns.

#Output pattern
FF FT TF TT
Function / meaning
0F F F FAlways false — contradiction / constant 0
1F F F TA AND B
2F F T FA AND NOT B
3F F T TA — output simply follows A
4F T F FNOT A AND B
5F T F TB — output simply follows B
6F T T FA XOR B
7F T T TA OR B
8T F F FA NOR B — NOT (A OR B)
9T F F TA XNOR B — A and B have the same truth value
10T F T FNOT B
11T F T TB implies A — B → A
12T T F FNOT A
13T T F TA implies B — A → B
14T T T FA NAND B — NOT (A AND B)
15T T T TAlways true — tautology / constant 1

AND, OR, XOR, NAND, NOR and XNOR are the names most often encountered in electronics, but mathematically they are only some of the sixteen possible ways two Boolean inputs can determine one Boolean output.

Example: implication is also a two-variable function

Suppose A means “the start button is pressed” and B means “the motor is allowed to run.” The statement “If A, then B” is written A → B.

ABA → BWhy?
FFTA made no promise because A did not occur.
FTTA did not occur, so the implication is not broken.
TFFThis is the one case that breaks “If A, then B.”
TTTA occurred and B followed.

Its output pattern is therefore T T F T, one of the sixteen patterns in the table above. The next tutorial will examine “if...then” reasoning more closely.

Three variables: work in stages

Now let:

  • A = the guard is closed
  • B = the start command is present
  • C = the stop condition is present

Suppose the motor-run condition is:

(A AND B) AND NOT C

With three variables we need 23 = 8 rows. Rather than trying to evaluate the entire expression mentally, create intermediate columns for A AND B and NOT C.

ABC A AND B NOT C (A AND B) AND NOT C
FFFFTF
FFTFFF
FTFFTF
FTTFFF
TFFFTF
TFTFFF
TTFTTT
TTTTFF

The final column shows that the motor may run only when the guard is closed, the start command is present, and the stop condition is absent.

A more complex expression

Truth tables become even more useful when several operations are nested. Consider:

(A OR B) AND (NOT C OR D)

With four variables, a complete table would contain 16 input rows. We do not need to solve the whole expression in one jump. Make one column for each step:

1. A OR B
2. NOT C
3. NOT C OR D
4. (A OR B) AND (NOT C OR D)

For one sample row, let A = F, B = T, C = T, D = F:

ABCDA OR BNOT CNOT C OR DFinal
FTTFTFFF

That same sequence is repeated for the other fifteen input combinations. Intermediate columns are not wasted work: they make it possible to see exactly where a result came from and greatly reduce mistakes.

Good habit: when an expression contains several operators, do not skip directly to the answer column. Add intermediate columns until each column performs only one simple logical operation.

Why language comes first

The old truth-table page made a particularly useful distinction between the two everyday meanings of “or.” That is exactly the kind of language habit that later determines whether a circuit does what its designer intended.

Try these yourself

A AND B is true when:
AND requires both conditions to be true.
In formal logic, ordinary inclusive OR is true when:
Inclusive OR includes the case where both statements are true.
“Turn left or right, but not both” is closest to:
XOR means one or the other, but not both.
How many input rows are required for a complete truth table with three independent variables?
A complete truth table has 2^n rows. With three variables, 2^3 = 8.
Two variables A and B have four input combinations. How many different Boolean output functions can those two variables produce?
There are four input rows, and each row can independently produce F or T. That gives 2^4 = 16 possible output patterns.
When solving a complex truth table, what is the safest method?
Intermediate columns let each step perform one simple operation, making the reasoning visible and reducing mistakes.