De Morgan's Boolean algebra laws state that the negation of an AND operation is equivalent to the OR operation of the negated inputs, and the negation of an OR operation is equivalent to the AND operation of the negated inputs. If you are wiring a motor interlock or writing a microcontroller safety check, this single principle lets you swap out missing logic chips, simplify messy PLC ladder rungs, and shave cents off a high-volume BOM.
Think of a bank vault security system. The vault opens only if the Manager AND the Guard turn their keys (AND). If you want to know when the vault is locked (the negation), it is locked if the Manager is absent OR the Guard is absent (OR). That is De Morgan's law in action.
The Core Rules: Break the Bar, Change the Sign
According to standard digital logic references like All About Circuits, De Morgan's theorems provide the mathematical bridge between AND and OR gates when inversions are involved. The two foundational equations are:
- Rule 1 (NAND to OR):
NOT (A AND B) = (NOT A) OR (NOT B) - Rule 2 (NOR to AND):
NOT (A OR B) = (NOT A) AND (NOT B)
In Boolean notation, this is written as:
(A · B)' = A' + B'(A + B)' = A' · B'
This is not just abstract math; it is the foundation of "universal logic." Because you can convert any AND/OR function into a combination of NAND or NOR gates, silicon manufacturers can standardize their fabrication processes. As noted by Electronics Tutorials, this universality is why NAND gates are the most densely packed and cost-effective logic gates on the market.
| Standard Function | Boolean Expression | De Morgan Equivalent | Practical IC Swap |
|---|---|---|---|
| AND | A · B | (A' + B')' | 74HC08 (AND) to 74HC02 (NOR) |
| OR | A + B | (A' · B')' | 74HC32 (OR) to 74HC00 (NAND) |
| NAND | (A · B)' | A' + B' | Use as inverted-input OR |
| NOR | (A + B)' | A' · B' | Use as inverted-input AND |
Worked Numeric Example: Standardizing on NAND Gates
Let's look at what this changes in a real circuit installation. Suppose you are designing a control board for a 24V DC conveyor motor. You need a NAND function for a thermal overload interlock, and an OR function for a high-limit switch bypass.
Normally, you would place two ICs on your BOM: a 74HC00 (Quad 2-Input NAND) and a 74HC32 (Quad 2-Input OR). In single quantities, a through-hole 74HC00N costs about $0.15, and the 74HC32N costs another $0.15.
Using De Morgan's law, we know that A OR B = (A' NAND B')'. We can build the OR function entirely out of the 74HC00 NAND gates by wiring three of its four internal gates:
- Gate 1 (Invert A): Tie Pins 1 and 2 together to input A. Output is at Pin 3 (A').
- Gate 2 (Invert B): Tie Pins 4 and 5 together to input B. Output is at Pin 6 (B').
- Gate 3 (NAND them): Feed Pin 3 into Pin 9, and Pin 6 into Pin 10. The final OR output is at Pin 8.
You have now eliminated the 74HC32 from your design. In a 10,000-unit production run, standardizing on a single 74HC00 IC saves roughly $1,500 in direct BOM costs, not including the reduced pick-and-place setup time, fewer feeder slots required, and lower inventory management overhead.
Where You Meet This in Practice
Embedded C and Microcontroller Logic
When writing safety interlocks in C for an 8-bit AVR (like the ATmega328P on an Arduino Uno) or a 32-bit ARM Cortex, you frequently evaluate compound conditions. Consider a scenario where a motor should fault if it is not true that both the proximity sensor and the encoder are active:
if (!(sensor_A && sensor_B)) { trigger_fault(); }
Applying De Morgan's law transforms this into:
if (!sensor_A || !sensor_B) { trigger_fault(); }
While modern compilers like avr-gcc or ARM GCC will often optimize both statements into identical assembly, explicitly writing the De Morgan equivalent prevents the compiler from generating deep, stack-heavy nested branches in highly complex, multi-variable conditions. It also makes the code vastly easier for a human maintainer to read during a 2 AM debugging session.
PLC Ladder Logic (IEC 61131-3)
In industrial automation, PLC ladder logic relies heavily on De Morgan's theorem to simplify rungs. If a rung requires a pump to run when not (Tank Full AND Valve Closed), using a block inversion symbol makes the logic visually cluttered and harder to troubleshoot. By applying De Morgan's law, the programmer can draw two parallel branches with Normally Closed (NC) contacts for "Tank Full" and "Valve Closed." This scans faster on legacy PLC hardware and allows maintenance technicians to easily trace the logic with a multimeter.
Common Confusions and Mistakes
The most frequent mistake bench technicians and students make is forgetting to change the operator. If you break the bar over (A · B)', you must change the AND (·) to an OR (+). Leaving it as an AND yields a completely incorrect truth table.
Another major confusion is mixing up De Morgan's laws with the Distributive Law. The distributive law (A · (B + C) = (A · B) + (A · C)) deals with expanding terms across parentheses without involving a global negation. De Morgan's law strictly applies when an inversion (a NOT gate or a bar) covers an entire grouped operation. If there is no negation over the group, De Morgan's does not apply.
Frequently Asked Questions
How do you apply De Morgan's theorem to 3 or more variables?
The rule scales linearly regardless of how many inputs you have. The negation of a multi-input AND is the OR of all negated inputs. For example, NOT (A AND B AND C) becomes (NOT A) OR (NOT B) OR (NOT C). In Boolean notation: (A · B · C)' = A' + B' + C'. You simply break the long inversion bar into individual bars over each variable and flip every AND to an OR (or vice versa).
Why is De Morgan's law important in digital circuit design?
It is the mathematical proof that NAND and NOR gates are "universal." Because De Morgan's laws allow you to convert any AND/OR/NOT combination into purely NAND or purely NOR gates, silicon foundries can dedicate entire wafer production lines to a single gate type. This drives down the cost per gate, reduces propagation delay mismatches in ASICs, and allows designers to standardize their component libraries.
What is the difference between De Morgan's law and the distributive law?
De Morgan's law dictates how to distribute a negation (NOT) across a grouped AND or OR operation, requiring you to flip the operator inside the group. The distributive law dictates how to multiply or factor a non-negated variable across a grouped operation (e.g., A AND (B OR C) = (A AND B) OR (A AND C)). If there is an inversion bar covering the whole group, use De Morgan's; if there is no inversion bar, use the distributive law.






