Sub topic 2
Truth Tables and Checking Equivalence
Prerequisites and working model
Assume you know binary numbers, basic logic gates, and Boolean notation. In Boolean algebra, each variable has one of two values:
0means false.1means true.+means OR.- Juxtaposition, such as
AB, means AND. - A bar or apostrophe means NOT, so
A'means NOTA.
A Boolean expression is a function that maps input values to an output value. A truth table lists this mapping for every possible input combination.
For n input variables, a complete truth table has 2^n rows. Therefore, two variables need four rows, and three variables need eight rows.
Constructing a truth table
Consider:
\[ F(A,B)=A+B' \]
First list the input combinations. Then compute the complemented value B', followed by the OR operation.
| A | B | B' | F = A + B' |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
The rows usually use binary counting order. For variables A, B, and C, the rows are 000, 001, 010, through 111.
A truth table can also be represented by the rows where the function is 1. For the table above, the output is 1 at binary inputs 00, 10, and 11. Interpreting AB as a binary number gives minterm indices 0, 2, and 3:
\[ F(A,B)=\Sigma m(0,2,3) \]
The rows where the output is 0 are indices 1, so the corresponding maxterm notation is:
\[ F(A,B)=\Pi M(1) \]
These notations identify a function from its truth-table rows.
Checking functional equivalence
Two expressions are functionally equivalent if they produce the same output for every possible input combination. Write:
\[ F \equiv G \]
when this condition holds.
For example, De Morgan's identity claims:
\[ (A+B)' \equiv A'B' \]
Compare both expressions in a truth table.
| A | B | A + B | (A + B)' | A' | B' | A'B' |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
The final columns match in every row, so the expressions are equivalent.
from itertools import product
def equivalent(f, g, variables):
return all(
f(*values) == g(*values)
for values in product((0, 1), repeat=variables)
)
demorgan = equivalent(
lambda a, b: int(not (a or b)),
lambda a, b: int((not a) and (not b)),
2,
)
absorption = equivalent(
lambda a, b: a or (a and b),
lambda a, b: a,
2,
)
print(demorgan)
print(absorption)This program evaluates both expressions for all input rows. It prints True only when no row differs.
A reliable procedure
- List every input combination in binary-counting order.
- Add intermediate columns for NOT, AND, and OR operations.
- Compute each candidate expression separately.
- Compare the two output columns row by row.
- If one row differs, the expressions are not equivalent.
- If every row matches, the expressions are equivalent.
Exercise
Are the expressions AB + A'C and (A + C)(A' + B) equivalent? State how you would verify your answer.
Show answer
Yes. Expand the second expression: (A + C)(A' + B) = AA' + AB + A'C + BC = AB + A'C + BC. The consensus term BC is redundant, so the result is AB + A'C. A complete three-variable truth table also confirms equivalence.