Lably
Skip to content

De Morgan's laws

Pair of logical equivalences

  • 11 min read
  • 10 chapters

Learn it on Lably

The rules can be expressed in English as:

  • The negation of "A and B" is the same as "not A or not B".
  • The negation of "A or B" is the same as "not A and not B".

or

  • The complement of the union of two sets is the same as the intersection of their complements
  • The complement of the intersection of two sets is the same as the union of their complements

or

  • not (A or B) = (not A) and (not B)
  • not (A and B) = (not A) or (not B)

where "A or B" is an "inclusive or" meaning at least one of A or B rather than an "exclusive or" that means exactly one of A or B.

Another form of De Morgan's law is: A−(B∪C)=(A−B)∩(A−C)A−(B∩C)=(A−B)∪(A−C)

Applications of the rules include simplification of logical expressions in computer programs and digital circuit designs. De Morgan's laws are an example of a more general concept of mathematical duality.

Formal notation

The negation of conjunction rule may be written in sequent notation: ¬(P∧Q)⊢(¬P∨¬Q),and(¬P∨¬Q)⊢¬(P∧Q).

The negation of disjunction rule may be written as: ¬(P∨Q)⊢(¬P∧¬Q),and(¬P∧¬Q)⊢¬(P∨Q).

In rule form: negation of conjunction

¬(P∧Q)∴¬P∨¬Q¬P∨¬Q∴¬(P∧Q)

and negation of disjunction

¬(P∨Q)∴¬P∧¬Q¬P∧¬Q∴¬(P∨Q)

and expressed as truth-functional tautologies or theorems of propositional logic:

¬(P∧Q)↔(¬P∨¬Q),¬(P∨Q)↔(¬P∧¬Q).

where P and Q are propositions expressed in some formal system.

The generalized De Morgan's laws provide an equivalence for negating a conjunction or disjunction involving multiple terms.
For a set of propositions P1,P2,…,Pn, the generalized De Morgan's Laws are as follows: ¬(P1∧P2∧⋯∧Pn)↔¬P1∨¬P2∨…∨¬Pn¬(P1∨P2∨⋯∨Pn)↔¬P1∧¬P2∧…∧¬Pn

These laws generalize De Morgan's original laws for negating conjunctions and disjunctions.

Substitution form

De Morgan's laws are normally shown in the compact form above, with the negation of the output on the left and negation of the inputs on the right. A clearer form for substitution can be stated as:

(P∧Q)⟺¬(¬P∨¬Q),(P∨Q)⟺¬(¬P∧¬Q).

This emphasizes the need to invert both the inputs and the output, as well as change the operator when doing a substitution.

Set theory

In set theory, it is often stated as "union and intersection interchange under complementation", which can be formally expressed as: A∪B¯=A¯∩B¯,A∩B¯=A¯∪B¯,

where:

  • A¯ is the negation of A, the overline being written above the terms to be negated,
  • ∩ is the intersection operator (AND),
  • ∪ is the union operator (OR).

Unions and intersections of any number of sets

The generalized form is ⋂i∈IAi¯≡⋃i∈IAi¯,⋃i∈IAi¯≡⋂i∈IAi¯,

where I is some, possibly countably or uncountably infinite, indexing set.

In set notation, De Morgan's laws can be remembered using the mnemonic "break the line, change the sign".

Boolean algebra

In Boolean algebra, similarly, this law which can be formally expressed as: A∧B¯=A¯∨B¯,A∨B¯=A¯∧B¯,

where:

which can be generalized to

A1∧A2∧…∧An¯=A1¯∨A2¯∨…∨An¯,A1∨A2∨…∨An¯=A1¯∧A2¯∧…∧An¯.

Engineering

In electrical and computer engineering, De Morgan's laws are commonly written as: (A⋅B)¯≡(A¯+B¯)

and (A+B)¯≡(A¯⋅B¯),

where:

  • ⋅ is the logical AND,
  • + is the logical OR,
  • the overbar is the logical NOT of what is underneath the overbar.

Text searching

De Morgan's laws commonly apply to text searching using Boolean operators AND, OR, and NOT. Consider a set of documents containing the words "cats" and "dogs". De Morgan's laws hold that these two searches will return the same set of documents:

  • Search A: NOT (cats OR dogs)
  • Search B: (NOT cats) AND (NOT dogs)

The corpus of documents containing "cats" or "dogs" can be represented by four documents:

Document 1: Contains only the word "cats".
Document 2: Contains only "dogs".
Document 3: Contains both "cats" and "dogs".
Document 4: Contains neither "cats" nor "dogs".

To evaluate Search A, clearly the search "(cats OR dogs)" will hit on Documents 1, 2, and 3. So the negation of that search (which is Search A) will hit everything else, which is Document 4.

Evaluating Search B, the search "(NOT cats)" will hit on documents that do not contain "cats", which is Documents 2 and 4. Similarly the search "(NOT dogs)" will hit on Documents 1 and 4. Applying the AND operator to these two searches (which is Search B) will hit on the documents that are common to these two searches, which is Document 4.

A similar evaluation can be applied to show that the following two searches will both return Documents 1, 2, and 4:

  • Search C: NOT (cats AND dogs),
  • Search D: (NOT cats) OR (NOT dogs).

Sign in to keep reading

9 more chapters are free with a Lably account.

More in Foundations