Digital logic
De Morgan's laws
Also called: De Morgan · break the bar, change the sign · negating and/or
Definition
NOT (A AND B) equals (NOT A) OR (NOT B), and NOT (A OR B) equals (NOT A) AND (NOT B).
Picture it
Negating a combined condition flips every part and swaps AND with OR. 'Not (raining and cold)' means 'not raining or not cold'. Programmers use it to tidy if statements, and designers use it to swap gate types.
The maths
NOT(A · B) = Ā + B̄ NOT(A + B) = Ā · B̄
| Quantity | Unit | Symbol |
|---|---|---|
| ratio | dimensionless | 1 |
Worked example
Simplify the stop condition not (speed_ok and temp_ok). For how many of the four input combinations is it true?
- not (a and b) = (not a) or (not b)
- False only when both are true: 1 of 4 rows
- True in 4 − 1 = 3 rows
Answer(not speed_ok) or (not temp_ok): true in 3 of the 4 cases.
✓ The number in this answer is recomputed from scratch by an automated test.
logic tester
Logic gate tester
Y = 1
Y = A ⊕ B
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 ◀ now |
| 1 | 1 | 0 |
XOR with A = 1, B = 0 gives Y = 1.
Ideal gates: no propagation delay. 1 = true = high, 0 = false = low.
Common misconceptions
- Misconception: NOT (A AND B) is not (NOT A) AND (NOT B): you must swap the operator as well.
- Misconception: The laws extend to any number of inputs.