Digital Logic Toolkit — De Morgan’s laws
De Morgan's Laws
Push a negation through any expression and see both forms side by side.
Complement anything — a product, a sum, a whole sum of products — and the negation is pushed inward one named law at a time.
Check how this was read
- Read "AB" as A · B — 2 variables ANDed together. Declare "AB" as a variable name if you meant one variable.
read as ¬((A · B) + C)
Notation ▾
' is NOT and binds to the single item before it, so (A+B)' complements the whole group and AB' is A·(B′). The overbar is a grouping symbol — bracket whatever it is meant to cover. The full notation and precedence rules are below.
Toward the variables, until every complement sits on a single letter — negation normal form.
Start from a worked example
What you typed, read back
¬((A · B) + C)
Where each bar ends — the extent of a complement is its operand, and this is the reading that was used:
- the prime covers A · B + C — all of it
The answer
Negation normal form
(A′ + B′) · C′
This is a normalisation, not a minimisation. Pushing negations in stops as soon as every complement sits on a variable; the minimal forms are below, and where they differ from the answer above neither is wrong — they answer two different questions.
Pushing the negation in
| # | Working line | Law |
|---|---|---|
| 0 | (A · B + C)′ | start |
| 1 | (A · B)′ · C′ | De Morgan (A + B)' = A'·B' |
| 2 | (A′ + B′) · C′ | De Morgan (A·B)' = A' + B' |
Now in negation normal form: every prime sits on a single variable, which is the engine’s own stopping rule.
Step by step
Step 1De Morgan(A + B)' = A'·B'
with A = A · B, B = C
(A · B + C)′becomes(A · B)′ · C′
Method: De Morgan's laws; Shannon, A Symbolic Analysis of Relay and Switching Circuits (1938)
The check, row by row
De Morgan is the law students most want to check rather than take on faith, and the check costs 8 rows.
| A | B | C | before | after | agree? |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | agree |
| 0 | 0 | 1 | 0 | 0 | agree |
| 0 | 1 | 0 | 1 | 1 | agree |
| 0 | 1 | 1 | 0 | 0 | agree |
| 1 | 0 | 0 | 1 | 1 | agree |
| 1 | 0 | 1 | 0 | 0 | agree |
| 1 | 1 | 0 | 0 | 0 | agree |
| 1 | 1 | 1 | 0 | 0 | agree |
Both laws, always
The two forms are learned as a pair and half the errors are applying the wrong one, so the page states both whichever one your expression needed.
- (A · B)′ = A′ + B′
- (A + B)′ = A′ · B′
Break the bar, change the sign. Break the overbar over the whole expression into two overbars over the parts, and flip the operator between them. Both are proved row by row below.
Bubble pushing — the same law, drawn
Change the body (AND ↔ OR) and toggle the bubble on every input and on the output. Seeing the bubbles move is the explanation, and it is why NAND and NOR are universal.
Before — the expression as you typed it
Circuit description and netlist
Logic gate schematic. 3 inputs: A, B and C. 3 gates: 1 AND, 1 OR and 1 NOT. The output Y is driven by a NOT gate. The longest signal path passes through 3 gates.
The circuit computes Y = (A · B + C)′, read as ¬((A · B) + C).
| Gate | Type | Inputs | Output expression |
|---|---|---|---|
| g0 | AND | A, B | A · B |
| g1 | OR | g0, C | A · B + C |
| g2 | NOT | g1 | (A · B + C)′ |
Double bubble inserted — two inversions on a wire cancel
Circuit description and netlist
Logic gate schematic. 3 inputs: A, B and C. 7 gates: 1 AND, 1 OR and 5 NOT. The output Y is driven by a NOT gate. The longest signal path passes through 5 gates.
The circuit computes Y = ((A · B)′′ + C′′)′, read as ¬(¬¬(A · B) + ¬¬C).
| Gate | Type | Inputs | Output expression |
|---|---|---|---|
| g0 | AND | A, B | A · B |
| g1 | NOT | g0 | (A · B)′ |
| g2 | NOT | g1 | (A · B)′′ |
| g3 | NOT | C | C′ |
| g4 | NOT | g3 | C′′ |
| g5 | OR | g2, g4 | (A · B)′′ + C′′ |
| g6 | NOT | g5 | ((A · B)′′ + C′′)′ |
After — the pushed-in form
Circuit description and netlist
Logic gate schematic. 3 inputs: A, B and C. 5 gates: 1 AND, 1 OR and 3 NOT. The output Y is driven by an AND gate. The longest signal path passes through 3 gates.
The circuit computes Y = (A′ + B′) · C′, read as ((¬A + ¬B) · ¬C).
| Gate | Type | Inputs | Output expression |
|---|---|---|---|
| g0 | NOT | A | A′ |
| g1 | NOT | B | B′ |
| g2 | OR | g0, g1 | A′ + B′ |
| g3 | NOT | C | C′ |
| g4 | AND | g2, g3 | (A′ + B′) · C′ |
The same function as index lists
- Σm(0, 2, 4)
- ΠM(1, 3, 5, 6, 7)
Complementing turns a sum of products into a product of sums and back. Both lists, written out term by term.
Minimal forms
Minimal SOP
A′ · C′ + B′ · C′
Minimal POS
C′ · (A′ + B′)
POS is cheaper here — 2 terms · 3 literals as a product of sums against 2 terms · 4 literals as a sum of products.
Why you can trust the count
Two pipelines run over the same prime-implicant chart. The walkthrough uses essential primes, then minterm (“row”) dominance, then implicant (“column”) dominance, then Petrick’s method — the sequence a textbook shows, which reaches one correct answer.
The list of every minimum cover is produced by a second pipeline that uses essentials and minterm dominance only. Essential-prime extraction is safe for enumeration and minterm dominance is safe; implicant dominance is not — striking out a dominated prime discards every cover that used it, and some of those cost exactly the minimum.
So the walkthrough answers “what is an optimum?” and the list answers “what are all the optima?”. Both are shown because the textbook shows the first and the truth is the second.
Notation and operator precedence used here
· is AND, + is OR, a prime is NOT, ⊕ is XOR and ⊙ is XNOR. In the field, + is OR, juxtaposition and * are AND, ' is NOT, ^ is XOR, @ is XNOR, -> is implication and <-> is the biconditional. Precedence runs, highest to lowest: ( ) → NOT → AND → XOR / XNOR → NAND / NOR → OR → IMPLIES (right-associative) → IFF. The fully parenthesised reading is echoed back on every keystroke.
The overbar is a grouping symbol, and this page leans on that harder than any other. Its extent is its operand, and plain text cannot express that — so type ' or ¬( … ), and overbars are drawn on output only. Half of all De Morgan errors are really overbar-extent errors: (A·B)′ and A·B′ are different functions, and a hand-written bar that stops in the wrong place is the reason.
Postfix ′ binds to the single item immediately before it — a variable, a parenthesised group, or another prime. So AB' is A·(B′), (A+B)' complements the whole group, and A'' is A. And | means OR here, never the Sheffer stroke: in pure logic notation the bar is NAND, in every programming language it is OR, and that is the reading almost everyone arrives with. NAND is ↑ or the word NAND.
The two laws
(A · B)′ = A′ + B′
Not (both) is (not one) or (not the other).
(A + B)′ = A′ · B′
Not (either) is (not one) and (not the other).
The mnemonic that actually works: break the bar, change the sign. Break the overbar over the whole expression into two overbars over the parts, and flip the operator between them. The page opens on (AB + C)', which needs both laws in order — (A · B)′ · C′ by De Morgan, then (A′ + B′) · C′ by De Morgan — and lands on (A′ + B′) · C′.
The proof
Two proofs, because two audiences want different ones. By truth table is complete and checkable in ten seconds: four rows for each law, both columns and an agreement column. Every row below was computed by the engine when this page was built, and a law whose two sides stopped agreeing would fail the build rather than appear here as a false proof.
| A | B | (A · B)′ | A′ + B′ | agree? |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | agree |
| 0 | 1 | 1 | 1 | agree |
| 1 | 0 | 1 | 1 | agree |
| 1 | 1 | 0 | 0 | agree |
| A | B | (A + B)′ | A′ · B′ | agree? |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | agree |
| 0 | 1 | 0 | 0 | agree |
| 1 | 0 | 0 | 0 | agree |
| 1 | 1 | 0 | 0 | agree |
By uniqueness of the complement is the proof that generalises. To show A′ + B′ is the complement of A·B, show (A·B) + (A′ + B′) = 1 and (A·B) · (A′ + B′) = 0 — both verified at build time. Since an element of a Boolean algebra has exactly one complement, the two are equal.
That proof extends to any number of operands by induction on associativity, which a four-row table cannot do: (a₁ · a₂ · … · aₙ)′ = a₁′ + a₂′ + … + aₙ′ and (a₁ + a₂ + … + aₙ)′ = a₁′ · a₂′ · … · aₙ′. The three-operand case is verified in both directions: (A · B · C)′ is A′ + B′ + C′, and (A + B + C)′ is A′ · B′ · C′. A four-input NAND is therefore one gate, not a chain of two-input ones.
Why the bar is not distributive
Wrong: (A + B)′ = A′ + B′. A complement is not a factor and does not distribute over the operator underneath it — the operator itself changes. One disagreeing row is a proof and a paragraph is not: A = 0, B = 1 gives (A + B)′ = 0 but A′ + B′ = 1.
Right: (A + B)′ = A′ · B′.
Bubble pushing
De Morgan drawn instead of written — the same law, applied to a schematic. Four rewrites on the diagram:
- Two bubbles on one wire annihilate. That is Involution, drawn.
- A gate with an output bubble is the other gate with input bubbles. A NAND is an OR with both inputs inverted; a NOR is an AND with both inputs inverted.
- A two-level AND–OR network becomes NAND–NAND by inserting a bubble pair on every AND→OR wire. Nothing changes: each pair cancels.
- The dual holds for OR–AND, which becomes NOR–NOR the same way.
This is what makes NAND and NOR universal, and it is why IEEE Std 91 gives every gate an alternative symbol. Draw any expression and watch the bubbles move.
De Morgan in code
!(a && b) is !a || !b, and !(a || b) is !a && !b. Getting it wrong is a real bug, not only a lost mark — inverting a compound guard by adding one ! at the front and leaving the operator alone is one of the most common conditional errors there is.
Note that | in this toolkit is OR, never the Sheffer stroke. In pure logic notation the bar is NAND; in every programming language it is OR, and that is the reading almost everyone arrives with.
De Morgan for sets and for quantifiers
The same shape holds for set complement — (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ and (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ — and for quantifiers — ¬∀x P(x) ≡ ∃x ¬P(x) and ¬∃x P(x) ≡ ∀x ¬P(x) — because all three are Boolean algebras or behave like them. This is a digital-logic tool and not a set-theory one: the paragraph is here because those searches land here, and it does not pretend to be more. The truth-table generator handles the propositional half of that syllabus.
Where the complement is not the dual
The dual swaps · with + and 0 with 1 and leaves the literals alone. The complement does that and complements every literal: f ᵈ(x) = f′(x′), which is not f′. Confusing them is why a minimal POS must be derived by minimising the OFF-set and De Morganing each cube, and never by dualising the minimal SOP. Duality, in full.
Limits, stated plainly
The tool pushes negations through AND, OR, XOR, XNOR, NAND, NOR, implication and the biconditional. The derived operators are expanded to their definitions first, and the page names that step rather than performing it silently — so (A ⊕ B)′ begins with Definition of XOR and only then applies De Morgan.
The step-by-step derivation is limited to 6variables. Above that the answer, the truth-table check and the minimal forms are still exact — the answer comes from the engine's pushNegationsIn, which has no variable limit — and the page says so where the steps would have been rather than truncating quietly.
It does not minimise unless you ask. Negation normal form and minimal SOP are different destinations: this page opens on (AB + C)', whose NNF is (A′ + B′) · C′, whose minimal SOP is A′ · C′ + B′ · C′ and whose minimal POS is C′ · (A′ + B′) — with Σm(0, 2, 4) and ΠM(1, 3, 5, 6, 7). All of those numbers are computed by the engine at build time.
Worked examples
Worked examples
- (A·B)′introNAND expands to a sum
- (A + B)′introNOR expands to a product
- (A + B·C)′coretwo applications, outer then inner
- ((A + B)·C)′coreproduct of a sum, negated
- (A·B·C·D)′coren-input generalisation
- (Ā + B̄)′examDe Morgan then involution
- (A ⊕ B)′examXOR complement is XNOR
- (Ā·B + A·B̄)′edge casenegating a full SOP expression
Related
- De Morgan among the other thirteen laws — the whole axiom set, each with a proof
- Boolean algebra simplifier — simplify the pushed-in result
- Universal gates — why NAND and NOR are universal, which is this law
- Logic gate diagram builder — bubble pushing, drawn
- NAND gate — the complement of AND, as one gate
- NOR gate — the complement of OR, as one gate
- SOP and POS canonical forms — complementing turns SOP into POS
- Truth table generator — check any De Morgan rewrite row by row
- Karnaugh map solver — grouping the 0s instead of the 1s is De Morgan on a map
Sources
- De Morgan, Augustus. Formal Logic: or, The Calculus of Inference, Necessary and Probable. London: Taylor and Walton, 1847.
- De Morgan, Augustus. “On the Syllogism, No. III, and on Logic in General.” Transactions of the Cambridge Philosophical Society 10 (1858): 173–230.
- Boole, George. An Investigation of the Laws of Thought, on Which are Founded the Mathematical Theories of Logic and Probabilities. London: Walton and Maberly, 1854.
- Huntington, Edward V. “Sets of Independent Postulates for the Algebra of Logic.” Transactions of the American Mathematical Society 5, no. 3 (1904): 288–309. doi:10.2307/1986459 — uniqueness of the complement, which is the proof used here.
- Shannon, Claude E. “A Symbolic Analysis of Relay and Switching Circuits.” Transactions of the American Institute of Electrical Engineers 57, no. 12 (December 1938): 713–723. doi:10.1109/T-AIEE.1938.5057767 — the switching-circuit reading, which is bubble pushing.
- Sheffer, Henry M. “A Set of Five Independent Postulates for Boolean Algebras, with Application to Logical Constants.” Transactions of the American Mathematical Society 14, no. 4 (1913): 481–488. doi:10.2307/1988701 — for the note that | is OR here and not the Sheffer stroke.
- IEEE. IEEE Standard Graphic Symbols for Logic Functions. IEEE Std 91-1984 — the alternative (bubbled) gate symbols the gate-level view draws.