Sub topic 2
Boolean algebra, logic gates and duality
Prerequisites and scope
This chapter assumes you can convert between binary and hexadecimal, read a truth table, and manipulate ordinary algebra. It covers the laws of Boolean algebra, the standard gates, the duality principle, and how to simplify and prove identities algebraically. Canonical forms, Karnaugh maps and NAND/NOR-only design come in later chapters.
Boolean variables and operations
A Boolean variable takes one of two values, 0 or 1. Three basic operations build every other function.
- NOT (complement):
A'or¬A. It is 1 when A is 0. - AND (product):
A·B. It is 1 only when both inputs are 1. - OR (sum):
A+B. It is 1 when at least one input is 1.
In this notation + means OR, not arithmetic addition. So 1 + 1 = 1. This is the most common source of early mistakes.
Operator precedence, from highest to lowest, is NOT, then AND, then OR. So A + B·C' means A + (B·(C')).
Logic gates
A gate is a circuit that implements one Boolean operation. The table lists the standard two-input gates.
| Gate | Expression | Output is 1 when |
|---|---|---|
| AND | A·B | both inputs are 1 |
| OR | A+B | at least one input is 1 |
| NAND | (A·B)' | not both inputs are 1 |
| NOR | (A+B)' | both inputs are 0 |
| XOR | A⊕B = A'B + AB' | inputs differ |
| XNOR | (A⊕B)' = AB + A'B' | inputs are equal |
NOT has a single input. XOR and XNOR are not basic but appear constantly in adders and parity circuits.
Useful XOR facts:
A⊕0 = A,A⊕1 = A',A⊕A = 0,A⊕A' = 1.- XOR is commutative and associative. An n-input XOR outputs 1 when an odd number of inputs are 1 (odd parity).
- XNOR of two inputs is the complement of XOR. For three inputs,
A⊕B⊕Cis 1 for an odd number of ones, while a chain of XNORs behaves differently, so check the count of gates.
Laws of Boolean algebra
Each law below is listed with its dual. The pairing is deliberate and is explained in the duality section.
| Law | AND form | OR form |
|---|---|---|
| Identity | A·1 = A | A+0 = A |
| Null (domination) | A·0 = 0 | A+1 = 1 |
| Idempotent | A·A = A | A+A = A |
| Complement | A·A' = 0 | A+A' = 1 |
| Involution | (A')' = A | (A')' = A |
| Commutative | AB = BA | A+B = B+A |
| Associative | (AB)C = A(BC) | (A+B)+C = A+(B+C) |
| Distributive | A(B+C) = AB+AC | A+BC = (A+B)(A+C) |
| Absorption | A(A+B) = A | A+AB = A |
| De Morgan | (AB)' = A'+B' | (A+B)' = A'B' |
| Consensus | AB + A'C + BC = AB + A'C | (A+B)(A'+C)(B+C) = (A+B)(A'+C) |
Two entries deserve attention.
The second distributive law, A + BC = (A+B)(A+C), has no counterpart in ordinary algebra. Students often miss it, yet it is needed to convert sum-of-products into product-of-sums.
The consensus law removes a redundant term. In AB + A'C + BC, the term BC is the consensus of AB and A'C. It is covered whenever either of the other two is 1: if B=C=1, then either A=1 (so AB=1) or A=0 (so A'C=1).
De Morgan's theorem
De Morgan's laws say that complementing a product gives the sum of complements, and complementing a sum gives the product of complements. They extend to any number of variables:
(A·B·C)' = A' + B' + C'(A+B+C)' = A'·B'·C'
To complement a larger expression, work from the outside in. Complement each variable, swap AND with OR, and keep the grouping.
from itertools import product
def check_de_morgan():
for a, b, c in product([0, 1], repeat=3):
lhs = 1 - (a | b | c)
rhs = (1 - a) & (1 - b) & (1 - c)
assert lhs == rhs
return "De Morgan verified on all 8 rows"
print(check_de_morgan())Exhaustive checking over all input combinations is a valid proof technique for Boolean identities, because there are only 2^n rows. This is called perfect induction.
The duality principle
The dual of a Boolean expression is formed by:
- Swapping every AND with OR.
- Swapping every constant 0 with 1.
- Leaving the variables and their complements unchanged.
For example, the dual of A·(B' + 0) is A + (B'·1).
The duality principle states that if an identity is true, its dual is also true. This is why the laws in the table above come in pairs. You prove one half and the other follows.
Duality is not the same as complement. Complementing F gives F', which flips the function's values. The dual F^D is a different function. The two are related by:
F' (A, B, C) = F^D (A', B', C')
That is, you get the complement of F by taking the dual and complementing every variable, which is exactly De Morgan's theorem applied repeatedly.
A function is self-dual if F = F^D. The three-input majority function AB + BC + CA is self-dual. A self-dual function never has the same output on an input vector and its bitwise complement, so exactly half the truth table rows are 1.
Simplifying with algebra
Algebraic simplification applies the laws to shrink an expression. There is no fixed algorithm, but a few patterns cover most GATE questions.
Worked example 1: absorption and complement
Simplify F = AB + AB' + A'B.
- Combine the first two terms:
AB + AB' = A(B + B') = A. - Now
F = A + A'B. - Apply the second distributive law:
A + A'B = (A + A')(A + B) = A + B.
The result is F = A + B.
The useful shortcut is A + A'B = A + B. Its dual is A(A' + B) = AB.
Worked example 2: consensus
Simplify F = XY + X'Z + YZ.
By the consensus law, the term YZ is redundant, so F = XY + X'Z.
Worked example 3: complementing
Find F' for F = A(B + C') + A'B'.
- Apply De Morgan to the outer OR:
F' = [A(B + C')]' · (A'B')'. - Expand each factor:
[A(B + C')]' = A' + B'C, and(A'B')' = A + B. - Multiply:
F' = (A' + B'C)(A + B). - Distribute:
F' = A'A + A'B + AB'C + BB'C = A'B + AB'C.
Check by substituting A=1, B=0, C=1. Then F = 1·(0 + 0) + 0 = 0, so F' = 1. The formula gives 0 + 1·1·1 = 1. It matches.
Gate-level reading of expressions
An expression maps directly to a circuit. Each operator becomes a gate, and the nesting depth gives the number of gate levels. F = AB + CD is a two-level circuit: two AND gates feeding one OR gate. Fewer literals and fewer gates usually mean a cheaper and faster circuit, which is why minimization matters.
Common errors
- Treating
+as arithmetic addition and writingA + A = 2A. In Boolean algebraA + A = A. - Applying De Morgan's law without flipping the operator, for example writing
(A+B)' = A'+B'. - Distributing the complement bar over a product as
(AB)' = A'B'. The correct result isA' + B'. - Forgetting that
A + BCis not(A+B)C. The correct expansion is(A+B)(A+C). - Confusing the dual with the complement.
- Cancelling a term common to both sides of an equation, as in
AB = ACimpliesB = C. This is false. Take A=0, B=0, C=1. Boolean algebra has no division.
Verifying results
Two reliable checks apply to any simplification. First, write the truth table of the original and simplified forms and compare every row. Second, substitute a few input combinations by hand. For GATE questions with numerical options, substituting one or two test vectors often eliminates wrong choices faster than full simplification.
Exercise
Simplify F = (A + B)(A + B')(A' + C) using Boolean laws, and state the dual of the original expression.
Show answer
Combine the first two factors: (A + B)(A + B') = A + BB' = A + 0 = A. Then F = A(A' + C) = AA' + AC = AC. The dual of the original expression, swapping AND with OR, is AB + A·B' + A'·C, written as (A·B) + (A·B') + (A'·C).
Exercise
Is the function F = AB + A'C + BC self-dual? Use the consensus law in your answer.
Show answer
By consensus F = AB + A'C. Its dual is (A + B)(A' + C) = AA' + AC + A'B + BC = AC + A'B + BC, and by consensus this is AC + A'B. These are not the same function. For A=1, B=1, C=0, F = 1 but F^D = 0. So F is not self-dual.