Sub topic 4
Duality and De Morgan's laws
This chapter assumes you know the basic gates (AND, OR, NOT, NAND, NOR), can read a truth table, and have seen the identity, complement, distributive and absorption laws from the previous chapter. It covers the duality principle, De Morgan's laws, and the general method for complementing an expression. These tools feed directly into canonical forms and NAND/NOR design later in the tutorial.
The duality principle
The dual of a Boolean expression is formed by swapping every AND with OR, every OR with AND, every 0 with 1, and every 1 with 0. Variables and complement bars are left alone.
The principle of duality says this: if an identity is true, then its dual is also true. That is why the laws you have met come in pairs.
| Law | Identity | Dual |
|---|---|---|
| Identity | a + 0 = a | a · 1 = a |
| Null | a + 1 = 1 | a · 0 = 0 |
| Complement | a + a' = 1 | a · a' = 0 |
| Idempotent | a + a = a | a · a = a |
| Distributive | a + bc = (a + b)(a + c) | a(b + c) = ab + ac |
| Absorption | a + ab = a | a(a + b) = a |
| Consensus | ab + a'c + bc = ab + a'c | (a + b)(a' + c)(b + c) = (a + b)(a' + c) |
Why duality holds
Every axiom of Boolean algebra comes with a dual axiom. A proof of a theorem is a chain of axiom applications. Replace each step with its dual axiom, and you get a valid proof of the dual theorem. So you never need to prove both halves of a pair.
Dual versus complement
The dual and the complement are different things, and mixing them up is a common GATE mistake.
- The dual of f is written f^d. It swaps operators and constants but keeps the variables as they are.
- The complement of f is f'. It gives the opposite output for every input.
For example, take f = a·b + c.
- f^d = (a + b)·c
- f' = (a' + b')·c'
The two are related. The complement equals the dual with every variable complemented: f'(a, b, c) = f^d(a', b', c'). This relationship is exactly De Morgan's law in general form.
A function is self-dual if f = f^d. The majority function ab + bc + ca is self-dual. A self-dual function on n variables has exactly 2^(n-1) distinct possibilities per complementary pair of rows, so exactly half of its truth table rows are 1.
De Morgan's laws
De Morgan's laws describe how negation passes through AND and OR.
- (a · b)' = a' + b'
- (a + b)' = a' · b'
In words: the complement of an AND is the OR of the complements, and the complement of an OR is the AND of the complements.
Verifying with a truth table
| a | b | (ab)' | a' + b' | (a+b)' | a'b' |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 0 |
Columns 3 and 4 match on every row, and so do columns 5 and 6. The check below does the same comparison in code.
from itertools import product
def equivalent(f, g, n):
return all(f(*v) == g(*v) for v in product([0, 1], repeat=n))
# (a AND b)' == a' OR b'
print(equivalent(lambda a, b: int(not (a and b)),
lambda a, b: int((not a) or (not b)), 2))
# (a OR b)' == a' AND b'
print(equivalent(lambda a, b: int(not (a or b)),
lambda a, b: int((not a) and (not b)), 2))Both lines print True.
Generalization to n variables
De Morgan's laws extend to any number of terms:
- (x1 · x2 · … · xn)' = x1' + x2' + … + xn'
- (x1 + x2 + … + xn)' = x1' · x2' · … · xn'
You can prove this by induction, using the two-variable law at each step. In gate terms, an n-input NAND is an n-input OR of inverted inputs, and an n-input NOR is an n-input AND of inverted inputs.
Complementing a whole expression
The general rule for finding f' follows from De Morgan's laws applied repeatedly. Two methods give the same answer.
- Method A (apply De Morgan step by step). Push the bar inward one level at a time. Swap AND with OR at each level, and complement each variable.
- Method B (dual, then complement the literals). Take the dual of f and complement every literal.
Worked example
Find the complement of f = a·b' + c·(d + e').
Using Method A:
- f' = (a·b')' · (c·(d + e'))'
- (a·b')' = a' + b
- (c·(d + e'))' = c' + (d + e')' = c' + d'·e
- f' = (a' + b)(c' + d'e)
Using Method B:
- Dual of f: (a + b')·(c + d·e')
- Complement every literal: (a' + b)·(c' + d'·e)
Both give f' = (a' + b)(c' + d'e). Method B is faster in an exam because you make one pass over the expression.
Operator precedence in the dual
The dual does not change the grouping of the expression. It changes only which operator sits at each node of the parse tree. If the original has an implicit AND (written as adjacency) inside an OR, the dual needs explicit parentheses around the new OR inside the new AND.
| Original | Dual (correct) | Dual (wrong) |
|---|---|---|
| a + bc | a(b + c) | ab + c |
| ab + cd | (a + b)(c + d) | a + bc + d |
| a(b + c)d | a + bc + d | a + b + cd |
Using De Morgan's laws in practice
Converting between SOP and POS
De Morgan's laws turn a sum of products into a product of sums for the complement. If F = ab + cd, then:
F' = (ab + cd)' = (ab)' · (cd)' = (a' + b')(c' + d')
This is the same method used later to get a minimal POS form from a K-map. You group the zeros of F, which gives a minimal SOP for F'. Then you complement that expression with De Morgan's laws to get F as a product of sums.
Bubble pushing
In a circuit diagram, De Morgan's laws mean that an AND gate with inverted inputs and output is the same as an OR gate. The two forms are interchangeable.
| Gate | Equivalent form |
|---|---|
| NAND(a, b) | OR(a', b') |
| NOR(a, b) | AND(a', b') |
| AND(a, b) | NOR(a', b') |
| OR(a, b) | NAND(a', b') |
This table is the basis of the NAND-only and NOR-only designs in a later chapter.
Checking an answer quickly
To test whether two expressions are equal in an exam, you do not always need a full truth table. Pick one input where the expressions might differ and evaluate both. A single mismatch proves they are not equal. A match on one input proves nothing, so use this only to rule answers out.
Common errors
- Forgetting to complement the variables when you complement the whole expression. (a + b)' is a'b', not ab.
- Bar-splitting without changing the operator. (ab)' is not a'b'. It is a' + b'.
- Treating the dual as the complement. The dual keeps literals unchanged.
- Dropping parentheses. (a' + b')(c' + d') is not a' + b'c' + d'.
- Applying De Morgan to a bar that covers only one variable. In a'·b the bar covers a alone, and there is nothing to expand.
- Assuming that a double bar can be ignored in a nested expression without checking its extent. (a'b)'' equals a'b, and the double complement cancels only the bars it covers.
Self-dual and related checks for GATE
GATE questions often ask for a property of a function after dualizing or complementing it. A few facts are worth knowing.
- The dual of a NAND expression is not a NOR expression of the same variables. The dual of (ab)' is (a + b)', which is a NOR. This is the dual, not an equality, so the two functions differ.
- The dual of an XOR expression a ⊕ b is a ⊙ b (XNOR), because a ⊕ b = ab' + a'b has the dual (a + b')(a' + b) = ab + a'b'.
- For a function with minterm list m, the dual's truth table is the complement of f read with its inputs reversed: f^d(x) = (f(x'))'. So f^d has minterm j exactly when f has no minterm at the bitwise complement of j.
The last point gives a fast numerical method. Take f(A, B, C) = Σm(1, 2, 7). The bitwise complement of each minterm index is 6, 5, 0. The dual's minterms are every index whose complement is not in {1, 2, 7}. Index j has complement 7 − j, so we need 7 − j not in {1, 2, 7}, which means j not in {6, 5, 0}. So f^d = Σm(1, 2, 3, 4, 7).
from itertools import product
def f(a, b, c):
return int((a, b, c) in {(0, 0, 1), (0, 1, 0), (1, 1, 1)})
def dual(fn):
return lambda *v: 1 - fn(*[1 - x for x in v])
fd = dual(f)
minterms = [i for i, v in enumerate(product([0, 1], repeat=3)) if fd(*v)]
print(minterms)The output is [1, 2, 3, 4, 7], matching the hand calculation.
Exercise
Find the complement of F = (a + b')·(c' + d·e) and write it as a sum of products without any bar over more than one variable.
Show answer
Use Method B. The dual of F is a·b' + c'·(d + e). Complement every literal: a'·b + c·(d' + e'). Distribute to get a sum of products: F' = a'b + cd' + ce'. Check by Method A: F' = (a + b')' + (c' + de)' = a'b + c(de)' = a'b + c(d' + e'), which is the same expression.
Exercise
State the dual of the consensus identity ab + a'c + bc = ab + a'c, and explain why the dual is guaranteed to be true without a truth table.
Show answer
The dual is (a + b)(a' + c)(b + c) = (a + b)(a' + c). It is guaranteed because every Boolean algebra axiom has a dual axiom. Applying the dual axiom at each step of the proof of the original identity gives a valid proof of the dual identity.
Exercise
Is f = ab + bc + ca self-dual? Show your reasoning using the dual expression.
Show answer
The dual of f is (a + b)(b + c)(c + a). Expand: (a + b)(b + c) = ab + ac + b + bc = b + ac, using absorption. Then (b + ac)(c + a) = bc + ab + ac + ac = ab + bc + ac. This equals f, so f is self-dual.