Skip to main content

Prove De Morgan's theorems; XOR using NAND

Short answer

De Morgan's theorems: (A+B)' = A'·B' and (A·B)' = A'+B'. An XOR gate can be built with 4 NAND gates: Y = (A·(AB)')' · (B·(AB)')' = A⊕B.

State and prove De-Morgan's theorems with necessary diagrams. Construct XOR gate using minimum number of NAND gates.

De Morgan's theorems

De Morgan's theorems tell how to complement a sum or a product of variables.

Theorem 1: The complement of a sum equals the product of the complements.

A+B‾=Aˉ⋅Bˉ\overline{A + B} = \bar{A} \cdot \bar{B}

So a NOR gate equals a bubbled AND gate (AND with inverted inputs).

Theorem 2: The complement of a product equals the sum of the complements.

A⋅B‾=Aˉ+Bˉ\overline{A \cdot B} = \bar{A} + \bar{B}

So a NAND gate equals a bubbled OR gate (OR with inverted inputs).

Proof by truth table

ABA+BA+BA+B‾\overline{A+B}AˉBˉ\bar A \bar BABABAB‾\overline{AB}Aˉ+Bˉ\bar A + \bar B
00011011
01100011
10100011
11100100

Column 4 = column 5 and column 7 = column 8 for every input, so both theorems are proved.

Algebraic proof of Theorem 1: if X=A+BX = A + B and Y=AˉBˉY = \bar A \bar B, then X+Y=A+B+AˉBˉ=A+B+Bˉ=1X + Y = A + B + \bar A \bar B = A + B + \bar B = 1 and X⋅Y=AAˉBˉ+BAˉBˉ=0X \cdot Y = A \bar A \bar B + B \bar A \bar B = 0. Since X+Y=1X + Y = 1 and XY=0XY = 0, Y is the complement of X. Theorem 2 follows by duality.

Diagrams

 Theorem 1: NOR = bubbled AND
 A --|‾‾‾\             A --o|‾‾‾\
     | OR  )o-- Y   =       | AND )-- Y
 B --|___/             B --o|___/

 Theorem 2: NAND = bubbled OR
 A --|‾‾‾\             A --o|‾‾‾\
     | AND )o-- Y   =       | OR  )-- Y
 B --|___/             B --o|___/

 (o = inversion bubble)

XOR using minimum NAND gates

Y=A⊕B=ABˉ+AˉBY = A \oplus B = A\bar B + \bar A B. It can be built with 4 two-input NAND gates:

G1=AB‾G2=A⋅G1‾=A⋅AB‾‾G3=B⋅G1‾=B⋅AB‾‾Y=G2⋅G3‾=A AB‾+B AB‾=A(Aˉ+Bˉ)+B(Aˉ+Bˉ)=ABˉ+AˉB=A⊕B\begin{aligned} G_1 &= \overline{AB} \\ G_2 &= \overline{A \cdot G_1} = \overline{A \cdot \overline{AB}} \\ G_3 &= \overline{B \cdot G_1} = \overline{B \cdot \overline{AB}} \\ Y &= \overline{G_2 \cdot G_3} = A\,\overline{AB} + B\,\overline{AB} \\ &= A(\bar A + \bar B) + B(\bar A + \bar B) \\ &= A\bar B + \bar A B = A \oplus B \end{aligned}
 A --+-------------[NAND G2]--+
     |              |         |
     +--[NAND G1]---+         +--[NAND G4]-- Y
     |              |         |
 B --+-------------[NAND G3]--+

G1 output feeds one input of both G2 and G3; A goes to G2, B goes to G3; G2 and G3 feed G4.

ABG1G2G3Y
001110
011101
101011
110110

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 2 questions →