Sub topic 14
Boolean expressions and De Morgan's theorems
This chapter assumes you know the truth tables of the OR, AND, and NOT gates and can read a simple gate diagram. It also assumes you know that a digital signal takes only the values 0 and 1. Here you will learn to write a circuit as an algebraic expression, simplify it, and use De Morgan's theorems. The next chapter uses these theorems to show that NAND and NOR are universal gates.
Boolean expressions
A Boolean expression describes a logic circuit using variables that can only be 0 or 1. The three basic operations are written as follows.
| Gate | Symbol in an expression | Read as |
|---|---|---|
| OR | Y = A + B | A or B |
| AND | Y = A · B | A and B |
| NOT | Y = A̅ (bar over A) | not A |
The "+" here does not mean ordinary addition. In Boolean algebra, 1 + 1 = 1, because "true OR true" is true. The "·" is the same as AND, and it is often left out, so A·B is written AB.
Precedence matters. NOT is applied first, then AND, then OR. So A + B·C means A + (B·C), not (A + B)·C. Use brackets whenever you are unsure.
NAND and NOR are written with a bar over the whole result:
- NAND: Y = (A·B)̅, which is NOT of (A AND B).
- NOR: Y = (A + B)̅, which is NOT of (A OR B).
In plain text, this chapter writes a bar over a group as NOT(...) when the bar would be hard to read.
Writing an expression from a circuit
Work from the inputs toward the output. Label the output of each gate, then combine the labels.
Suppose A and B go into an AND gate, and the result goes into an OR gate along with C. The AND output is A·B, so the final output is Y = A·B + C.
Now suppose A and B go into an OR gate, and its output goes into a NOT gate. The final output is Y = NOT(A + B), which is the NOR function.
To find the output for given inputs, substitute the values step by step. For A = 1, B = 0, C = 0 in Y = A·B + C, the AND part gives 1·0 = 0, and then 0 + 0 = 0. So Y = 0.
Basic Boolean identities
These rules let you simplify an expression before you build or analyse a circuit. Each can be checked with a truth table.
| Rule | OR form | AND form |
|---|---|---|
| Identity | A + 0 = A | A·1 = A |
| Null | A + 1 = 1 | A·0 = 0 |
| Idempotent | A + A = A | A·A = A |
| Complement | A + A̅ = 1 | A·A̅ = 0 |
| Double negation | NOT(NOT A) = A | NOT(NOT A) = A |
| Commutative | A + B = B + A | A·B = B·A |
| Distributive | A + B·C = (A + B)·(A + C) | A·(B + C) = A·B + A·C |
Notice that each OR rule has an AND partner. You get one from the other by swapping + with · and 0 with 1. This pairing is called duality, and it is the idea behind De Morgan's theorems.
De Morgan's theorems
De Morgan's theorems say how a bar (NOT) passes through an AND or an OR.
- First theorem: NOT(A + B) = A̅ · B̅. The NOR of two inputs equals the AND of their complements.
- Second theorem: NOT(A · B) = A̅ + B̅. The NAND of two inputs equals the OR of their complements.
The rule to remember is: break the bar, change the sign. Break the bar over the group, and change + to · or · to +. Then put a bar over each variable.
Checking the theorems with a truth table
Check the second theorem for every input pair.
| A | B | A·B | NOT(A·B) | A̅ | B̅ | A̅ + B̅ |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
The NOT(A·B) column and the A̅ + B̅ column are identical in all four rows, so the theorem holds. The same method proves the first theorem.
The program below checks both theorems on every input combination.
from itertools import product
def NOT(a):
return 1 - a
def AND(a, b):
return a & b
def OR(a, b):
return a | b
first_ok = True
second_ok = True
for a, b in product((0, 1), repeat=2):
# First theorem: NOT(A + B) = (NOT A) . (NOT B)
if NOT(OR(a, b)) != AND(NOT(a), NOT(b)):
first_ok = False
# Second theorem: NOT(A . B) = (NOT A) + (NOT B)
if NOT(AND(a, b)) != OR(NOT(a), NOT(b)):
second_ok = False
print("First theorem holds: ", first_ok)
print("Second theorem holds:", second_ok)Both lines print True.
Gate-level meaning
The theorems give each gate an equivalent form with inverted inputs.
In each pair, the two paths give the same output for every input.
Extending to three variables
The theorems extend to any number of variables.
- NOT(A + B + C) = A̅ · B̅ · C̅
- NOT(A · B · C) = A̅ + B̅ + C̅
For a longer expression, apply the rule one bar at a time, working from the outermost bar inward.
Simplifying expressions
Worked example. Simplify Y = A·B + A·B̅.
- Factor out A: Y = A·(B + B̅).
- Use the complement rule, B + B̅ = 1: Y = A·1.
- Use the identity rule: Y = A.
So this circuit, which looks like it uses two AND gates, an OR gate, and a NOT gate, simply passes A through.
Worked example with De Morgan. Simplify Y = NOT(A̅ + B).
- Apply the first theorem: Y = NOT(A̅) · B̅.
- Use double negation: Y = A · B̅.
A useful absorption rule is A + A·B = A. Proof: A + A·B = A·(1 + B) = A·1 = A.
Common errors
- Bar over the group versus bars over the variables. NOT(A·B) is not equal to A̅·B̅. The sign must change when the bar is broken. Test with A = 1, B = 0: NOT(A·B) = 1, but A̅·B̅ = 0·1 = 0.
- Treating + as ordinary addition. In Boolean algebra, A + A = A, not 2A.
- Ignoring precedence. A + B·C is not the same as (A + B)·C. At A = 1, B = 0, C = 0, the first is 1 and the second is 0.
- Breaking only part of a bar. In NOT(A·B + C), apply the theorem to the outer OR first: it gives NOT(A·B) · C̅, then A̅ + B̅ inside, so the answer is (A̅ + B̅)·C̅.
A NEET-style example
Question: what single gate is equivalent to a NOR gate followed by a NOT gate?
The NOR output is NOT(A + B). A NOT gate after it cancels the bar, so Y = A + B. That is an OR gate.
A second type: an OR gate has inputs A̅ and B̅, followed by a NOT gate. The output is Y = NOT(A̅ + B̅). By the first theorem this equals NOT(A̅)·NOT(B̅) = A·B, which is an AND gate.
Exercise
Simplify Y = NOT(A·B̅) + A·B using De Morgan's theorems and the Boolean identities. Then find Y for A = 0, B = 1.
Show answer
Apply the second theorem to the first term: NOT(A·B̅) = A̅ + B (the double bar on B cancels). So Y = A̅ + B + A·B. By absorption, B + A·B = B, so Y = A̅ + B. For A = 0, B = 1: A̅ = 1, so Y = 1 + 1 = 1.
Exercise
A student writes NOT(A + B) = A̅ + B̅. Give a pair of values for A and B that shows this is wrong, and write the correct expression.
Show answer
Take A = 1, B = 0. Then NOT(A + B) = NOT(1) = 0, but A̅ + B̅ = 0 + 1 = 1. The correct expression, by the first De Morgan theorem, is NOT(A + B) = A̅ · B̅, which gives 0 · 1 = 0.