De Morgan's laws exchange logical conjunction and logical disjunction when a logical negation moves across them:
Here denotes logical equivalence: the two propositional formulas agree under every Boolean valuation.[ref]
A complete verification uses the four rows of a truth table. In input order , both sides of the first logical equivalence have output sequence ; both sides of the second have . A proof in words is equally short: failure of “both” means at least one failure, whereas failure of “at least one” means both fail. The differing middle rows explain why simply pushing logical negation inward without changing AND to OR is wrong.
For the events in Boolean operations on events, the corresponding set identities are
One can prove these identities by checking an arbitrary set element : its two membership truth values obey De Morgan's laws. The same reasoning works for any two subsets of a common universal set.
Figure 1.
De Morgan's laws shade the same set whether a compound event is complemented first or its component events are complemented first
. Details.
For a nested program test, let mean “backup recent”, mean “backup verified”, and mean “manual override authorized”. Rejecting when neither an acceptable backup nor an override is present gives
The transformed condition reads “backup stale or unverified, and no override”. Apply the second of De Morgan's laws at the outside, then the first at the inner logical conjunction. For it rejects; changing only to one makes it accept. With Boolean operands in Python, not ((recent and verified) or override) and ((not recent) or (not verified)) and (not override) have the same result and inspect the operands in the same order, with the same skipped operands.
For a Boolean function of input bits, define its De Morgan dual by complementing every input, applying , and complementing the output:
De Morgan's laws say that the De Morgan dual of logical conjunction is logical disjunction, and conversely. The constant zero Boolean function becomes constant one. This is different from merely negating the output: for AND, output logical negation gives one at , whereas the De Morgan dual gives zero there.
Taking the De Morgan dual twice restores the original Boolean function:
Here each input is complemented twice as well. For a Boolean formula built from AND, OR, NOT and constants, its De Morgan dual can therefore be obtained by exchanging AND with OR and zero with one throughout, leaving input names and NOT in place. A structural induction proves the rule: it holds for an input and each constant, De Morgan's laws handle the two binary logical connectives, and double logical negation handles NOT. This symmetry lets one translate a complex test systematically instead of guessing where its failures occur.

Articles by others on the same topic (1)

De Morgan's laws are fundamental rules in both set theory and propositional logic that describe the relationship between conjunctions (AND operations) and disjunctions (OR operations) through negation. They are named after the British mathematician Augustus De Morgan.