# Fundamental Hardware Elements of Computers: De Morgan's Laws

 ← Boolean identities De Morgan's Laws Gate conversion →

De Morgan's laws are used to simplify Boolean equations so that you can build equations only involving one sort of gate, generally only using NAND or NOR gates. This can lead to cheaper hardware. There are two laws that you need to remember:

Rule 1 ${\displaystyle {\overline {P.Q}}={\overline {P}}+{\overline {Q}}}$ ${\displaystyle {\overline {P+Q}}={\overline {P}}.{\overline {Q}}}$

An easy way to remember De Morgan's Laws is through the rhyme: "break the line, change the sign"!

Let's prove that I'm not lying to you by creating a truth table to prove that: ${\displaystyle {\overline {P+Q}}={\overline {P}}.{\overline {Q}}}$

P Q ${\displaystyle {P}+{Q}}$ ${\displaystyle {\overline {P+Q}}}$ ${\displaystyle {\overline {P}}}$ ${\displaystyle {\overline {Q}}}$ ${\displaystyle {\overline {P}}.{\overline {Q}}}$
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

Since the values in the 4th and last columns are the same for all rows (which cover all possible truth value assignments to the variables), we can conclude that the two expressions are logically equivalent.

Now we prove ${\displaystyle {\overline {P.Q}}={\overline {P}}+{\overline {Q}}}$ by the same method:

P Q ${\displaystyle {P}.{Q}}$ ${\displaystyle {\overline {P.Q}}}$ ${\displaystyle {\overline {P}}}$ ${\displaystyle {\overline {Q}}}$ ${\displaystyle {\overline {P}}+{\overline {Q}}}$
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

We'll use ${\displaystyle P}$ to stand for padlock 1 is open, and ${\displaystyle Q}$ to stand for padlock 2 is open.

You can go through the gate if padlock 1 is open AND padlock 2 is open (${\displaystyle P.Q}$) You can not go through the gate if padlock 1 is locked OR padlock 2 is locked (${\displaystyle {\overline {P}}+{\overline {Q}}}$)

Since 'You can not go through the gate' is the same as the opposite (negation) of 'You can go through the gate' and, remembering

gate is open = ${\displaystyle P.Q}$ gate is closed = ${\displaystyle {\overline {P}}+{\overline {Q}}}$ you should be able to see that NOT{gate is open} = ${\displaystyle {\overline {P}}+{\overline {Q}}}$ or

${\displaystyle {\overline {P.Q}}}$ = ${\displaystyle {\overline {P}}+{\overline {Q}}}$

Example: Simplifying boolean equations using boolean algebra

Simplify the following: ${\displaystyle {\overline {(A.{\overline {B}})+{\overline {A}}}}}$

${\displaystyle A}$ ${\displaystyle B}$ ${\displaystyle {\overline {A}}}$ ${\displaystyle {\overline {B}}}$ ${\displaystyle A.{\overline {B}}}$ ${\displaystyle (A.{\overline {B}})+{\overline {A}}}$ ${\displaystyle {\overline {(A.{\overline {B}})+{\overline {A}}}}}$
0 0
1
1
0
1
0
0 1
1
0
0
1
0
1 0
0
1
1
1
0
1 1
0
0
0
0
1

From looking at the truth table we can see that it equates to ${\displaystyle A.B}$. But we should also know how to get to this result by using boolean identities. Let's give it a go:

1. Using De Morgans Law: ${\displaystyle {\overline {P+Q}}={\overline {P}}.{\overline {Q}}}$. Where P = ${\displaystyle (A.{\overline {B}})}$ and Q = ${\displaystyle ({\overline {A}})}$
2. Take each side separately and applying De Morgans Law convert the centre gate to an AND:
${\displaystyle {\overline {(A.{\overline {B}})+({\overline {A}})}}=({\overline {A.{\overline {B}}}}).({\overline {\overline {A}}})}$
3. Now dealing with the left hand side of our new equation (${\displaystyle {\overline {A.{\overline {B}}}}}$), apply De Morgans Law again (${\displaystyle {\overline {P.Q}}=={\overline {P}}+{\overline {Q}}}$) and cancel out the double bars:
${\displaystyle ({\overline {\overline {{\overline {A}}+{\overline {\overline {B}}}}}}).({A})=({\overline {A}}+{B}).({A})}$
4. Multiply out both sides:
${\displaystyle ({\overline {A}}.A)+(B.A)}$
5. From the Identity ${\displaystyle {\overline {A}}.A=0}$ we can replace the left hand side:
${\displaystyle 0+(B.A)}$
6. From the Identity ${\displaystyle 0+X=X}$ we can ignore the 0 leaving us with:
${\displaystyle B.A}$
7. From the Identity ${\displaystyle X.Y=Y.X}$ we can swap the values around:
${\displaystyle A.B}$ = the value we calculated by truth table

Let's try another

Exercise: Simplifying boolean equations
Simplify the following using De Morgan's Laws and boolean identities. Check your answers by making truth tables:

${\displaystyle {\overline {A.B}}+A}$

1. Using Demorgans rule that: ${\displaystyle {\overline {A.B}}={\overline {A}}+{\overline {B}}}$
2. Making ${\displaystyle {\overline {A.B}}+A={\overline {A}}+{\overline {B}}+A}$
3. Using the boolean identity that ${\displaystyle {\overline {A}}+A=1}$
4. Making ${\displaystyle {\overline {A}}+{\overline {B}}+A={\overline {B}}+1}$
5. Using the boolean identity that ${\displaystyle {\overline {B}}+1=1}$
6. We simplify down to ${\displaystyle {\overline {A.B}}+A==1}$

${\displaystyle {\overline {(A+{\overline {B}}).{\overline {A}}}}}$

${\displaystyle A}$ ${\displaystyle B}$ ${\displaystyle {\overline {A}}}$ ${\displaystyle {\overline {B}}}$ ${\displaystyle A+{\overline {B}}}$ ${\displaystyle (A+{\overline {B}}).{\overline {A}}}$ ${\displaystyle {\overline {(A+{\overline {B}}).{\overline {A}}}}}$
0 0
1
1
1
1
0
0 1
1
0
0
0
1
1 0
0
1
1
0
1
1 1
0
0
1
0
1

If you're catching on to this, you'll notice that this is the equivalent of ${\displaystyle A+B}$. But we better check it with boolean algebra identities and De Morgans Law to confirm we have the correct answer.

1. Using De Morgans Law: ${\displaystyle {\overline {P.Q}}={\overline {P}}+{\overline {Q}}}$
2. Take each side separately and applying De Morgans Law convert the centre gate to an AND:
${\displaystyle {\overline {(A+{\overline {B}}).({\overline {A}})}}={({\overline {A+{\overline {B}}}})+({\overline {\overline {A}}})}}$
3. Cancel out the double bars:
${\displaystyle {({\overline {A+{\overline {B}}}})+({\overline {\overline {A}}})}=({\overline {A+{\overline {B}}}})+({A})}$
4. Now dealing with the left hand side of our new equation, apply De Morgans Law again and cancel out the double bars:
${\displaystyle ({\overline {\overline {{\overline {A}}.{\overline {\overline {B}}}}}})+({A})=({\overline {A}}.{B})+({A})}$
5. Multiply out both sides:
${\displaystyle ({\overline {A}}+A).(B+A)}$
6. From the Identity ${\displaystyle {\overline {A}}+A=1}$ we can replace the left hand side:
${\displaystyle 1.(B+A)}$
7. From the Identity ${\displaystyle 1.X=X}$ we can ignore the 1 leaving us with:
${\displaystyle B+A}$
8. From the Identity ${\displaystyle X+Y=Y+X}$ we can swap the values around:
${\displaystyle A+B}$ = the value we calculated by truth table

${\displaystyle {\overline {({\overline {A+B}})+B}}}$

${\displaystyle A}$ ${\displaystyle B}$ ${\displaystyle A+B}$ ${\displaystyle {\overline {A+B}}}$ ${\displaystyle ({\overline {A+B}})+B}$ ${\displaystyle {\overline {({\overline {A+B}})+B}}}$
0 0
0
1
1
0
0 1
1
0
1
0
1 0
1
0
0
1
1 1
1
0
1
0
${\displaystyle {\overline {({\overline {A+B}})+B}}}$


If you're catching on to this, you'll notice that this is the equivalent of ${\displaystyle A.{\overline {B}}}$. But we better check it with boolean algebra identities and De Morgans Law to confirm we have the correct answer.

1. Using De Morgans Law: ${\displaystyle {\overline {P.Q}}={\overline {P}}+{\overline {Q}}}$
2. Take each side separately (P=${\displaystyle {\overline {A+B}}}$ and Q=${\displaystyle B}$) and applying De Morgans Law convert the centre gate to an AND:
${\displaystyle {\overline {({\overline {A+B}})+B}}=({\overline {\overline {A+B}}}).{\overline {B}}}$
3. Cancel out the double bars:${\displaystyle ({\overline {\overline {A+B}}}).{\overline {B}}=(A+B).{\overline {B}}}$
4. Multiply out both sides:
${\displaystyle (A.{\overline {B}})+(B.{\overline {B}})}$
5. From the Identity ${\displaystyle (B.{\overline {B}})=0}$ we can replace the right hand side:
${\displaystyle (A.{\overline {B}})+0}$
6. From the Identity ${\displaystyle X+0=X}$ we can ignore the 0 leaving us with:
${\displaystyle A.{\overline {B}}}$ = the value we calculated by truth table