Understanding De Morgan’s Laws
Explore De Morgan’s Laws, which describe how negation interacts with AND and OR operations. Learn how to apply these laws to simplify logical expressions.
Intermediate
15 min
Negation — the operation that flips true to false and vice versa — is one of the most powerful tools in Boolean Algebra. But when negation interacts with combined conditions like AND or OR, the behavior can become tricky. That’s where de Morgan’s Laws come in. These laws provide a clear, systematic way to distribute negation across expressions, transforming ANDs into ORs (and vice versa) while negating each variable. Understanding these laws is essential for simplifying complex logic, avoiding mistakes, and implementing logic efficiently in both software and hardware.
Introduction
In the previous lesson, you encountered the rules and laws of Boolean Algebra. Now, we’ll dive deeper into these powerful rules. De Morgan’s Laws state that the negation of a disjunction (OR) is the conjunction (AND) of the negations, and the negation of a conjunction (AND) is the disjunction (OR) of the negations.
Symbolically:
- ¬(A + B) = ¬A · ¬B
- ¬(A · B) = ¬A + ¬B
These equivalences not only help in rewriting and simplifying Boolean expressions but also form the basis for designing logic circuits using NAND and NOR gates. In programming, these laws help rewrite conditions to make them clearer or more efficient.
In this lesson, we’ll explore the meaning of these laws, see truth tables that prove their validity, and learn how to apply them to solve practical logic problems.
The Laws Explained
De Morgan’s Laws describe how to distribute negation (NOT, ¬) over the two fundamental Boolean operations:
OR and AND. They show that negating a compound expression flips the operation inside and negates each
component individually.
Law 1: Negation of OR
¬(A + B) = ¬A · ¬B
This means that the negation of an OR expression is the same as the AND of the negations.
Law 2: Negation of AND
¬(A · B) = ¬A + ¬B
Similarly, the negation of an AND expression equals the OR of the negations.
Truth Table Proof
Let’s verify both laws with truth tables.
| A | B | ¬(A + B) | ¬A · ¬B | Equal? |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | ✔️ |
| 0 | 1 | 0 | 0 | ✔️ |
| 1 | 0 | 0 | 0 | ✔️ |
| 1 | 1 | 0 | 0 | ✔️ |
The columns ¬(A + B) and ¬A · ¬B are identical, confirming the first law.
| A | B | ¬(A · B) | ¬A + ¬B | Equal? |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | ✔️ |
| 0 | 1 | 1 | 1 | ✔️ |
| 1 | 0 | 1 | 1 | ✔️ |
| 1 | 1 | 0 | 0 | ✔️ |
Here, ¬(A · B) and ¬A + ¬B match perfectly, proving the second law.
In short:
- To negate A OR B, you negate both A and B and change OR to AND.
- To negate A AND B, you negate both A and B and change AND to OR.
Why De Morgan’s Laws Matter
De Morgan’s Laws are fundamental tools in both theory and practice of Boolean logic. Here’s why they’re so important:
-
Simplification of Expressions: Complex Boolean expressions often contain negations over ANDs or ORs. De Morgan’s Laws allow you to rewrite these expressions into simpler or more convenient forms, making them easier to understand, analyze, or optimize.
-
Digital Circuit Design: Many digital circuits rely on NAND and NOR gates, which are functionally complete. Using De Morgan’s Laws, you can convert AND/OR combinations with negations into circuits using only NAND or NOR gates, reducing hardware complexity and cost.
-
Programming Logic: In software, conditions are frequently negated. Applying De Morgan’s Laws helps rewrite conditions like
!(A || B)into!A && !B, which can be clearer and sometimes more efficient in code. -
Error Prevention: Misunderstanding how negation distributes can lead to bugs in both code and hardware. De Morgan’s Laws provide a reliable method to correctly handle negations in compound logic.
Key Takeaways
-
De Morgan’s Laws:
- ¬(A + B) = ¬A · ¬B
- ¬(A · B) = ¬A + ¬B
-
These laws enable you to rewrite negated ORs as ANDs of negations, and negated ANDs as ORs of negations.
-
Truth tables prove that both sides of each law are logically equivalent in all cases.
-
They are widely used in logic simplification, digital circuit design (especially NAND/NOR implementations), and programming to rewrite conditional statements.
-
Correct application of these laws prevents logical errors and helps you optimize both hardware and software logic.