Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Mathematics
  • Number System and Arithmetic
  • Algebra
  • Trigonometry
  • Statistics
  • Probability
  • Geometry
  • Mensuration
  • Calculus
  • Logarithms
Open In App
Next Article:
De Morgan's Law - Theorem, Proofs, Formula & Examples
Next article icon

De Morgan's Law - Theorem, Proofs, Formula & Examples

Last Updated : 28 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

De Morgan's law is the law that gives the relation between union, intersection, and complements in set theory. In Boolean algebra, it gives the relation between AND, OR, and complements of the variable, and in logic, it gives the relation between AND, OR, or Negation of the statement. With the help of De Morgan's Law, we can optimize various Boolean circuits involving logic gates, which help us perform the same operation but with very few apparatus.

In this article, we will learn about De Morgan's law, De Morgan's law in set theory, and De Morgan's law in Boolean algebra, along with its proofs, truth tables, and logic gate diagrams.

Table of Content

  • De Morgan's Law in Set Theory
  • First De Morgan's Law
  • Second De Morgan's Law
  • De Morgan's Law in Boolean Algebra
  • De Morgan's Law Formula
  • Solved Question on De Morgan's Law
  • Logic Applications of De Morgan's Law

De Morgan's Law in Set Theory

De Morgan's law in set theory defines the relationship between the union, intersection, and complements of the sets, and is given for both the complement of the union and the intersection of two sets. In set theory, there are two De Morgan's Laws that are:

  • First De Morgan's Law
  • Second De Morgan's Law

Let's understand these laws in detail as below:

First De Morgan's Law

First De Morgan's law states that "The complement of the union of two sets is equal to the intersection of the complements of each set."

Let A and B be two sets, then mathematically First De Morgan's Law is given as:

(A ∪ B)' = A' ∩ B'

Where 

  • U represents the Union operation between sets,
  • ∩ represents the intersection operation between sets, and 
  • ' represents complement operation on a set.

It is also called De Morgan's Law of Union.

Detail the Proof of De Morgan's Law

StepExplanation
Step 1: State the LawDe Morgan's Law includes two parts: ¬(A ∪ B) = ¬A ∩ ¬B and ¬(A ∩ B) = ¬A ∪ ¬B.
Step 2: Choose an ElementLet's prove ¬(A ∪ B) = ¬A ∩ ¬B. Assume an element x that is not in A ∪ B.
Step 3: Understand the AssumptionIf x is not in A ∪ B, then x is neither in A nor in B.
Step 4: Apply the DefinitionBy the definition of complement, if x is not in A and not in B, then x is in ¬A and in ¬B.
Step 5: Conclude the ProofSince x is in both ¬A and ¬B, x is in ¬A ∩ ¬B. Thus, we've shown ¬(A ∪ B) = ¬A ∩ ¬B.

Proof Using Algebra of Sets

We need to prove, (A ∪ B)' = A' ∩ B'
Let X = (A ∪ B)' and Y = A' ∩ B'
Let p be any element of X, then p ∈ X ⇒ p ∈ (A ∪ B)'
⇒ p ∉ (A ∪ B)
⇒ p ∉ A or p ∉ B
⇒ p ∈ A' and p ∈ B'
⇒ p ∈ A' ∩ B'
⇒ p ∈ Y

∴ X ⊂ Y              . . . (i)

Again, let q be any element of Y, then q ∈ Y ⇒ q ∈ A' ∩ B'
⇒ q ∈ A' and q ∈ B'
⇒ q ∉ A and q ∉ B
⇒ q ∉ (A ∪ B)
⇒ q ∈ (A ∪ B)'
⇒ q ∈ X

∴ Y ⊂ X              . . . (ii)

From (i) and (ii) X = Y

(A ∪ B)' = A' ∩ B'

Also Read - Proof of De-Morgan’s laws in boolean algebra

Proof Using a Venn Diagram

Venn Diagram for (A ∪ B)'

Venn Diagram for (A ∪ B)'

Venn Diagram for A' ∩ B'

Venn Diagram for A' ∩ B'

From both Diagrams, we can clearly say,

(A ∪ B)' = A' ∩ B'

That is the First De Morgan's Law.

Second De Morgan's Law

Second, De Morgan's law states that "The complement of intersection of two sets is equal to the union of the complements of each set."

Let A and B be two sets, then mathematically First De Morgan's Law is given as:

(A ∩ B)' = A' ∪ B'

Where 

  • U represents the Union operation between sets,
  • ∩ represents the intersection operation between sets, and 
  • ' represents complement operation on a set.

It is also called De Morgan's Law of Intersection.

Proof Using Algebra of Sets

Second De Morgan's law: (A ∩ B)' = A' ∪ B'

Let X = (A ∩ B)' and Y = A' ∪ B'
Let p be any element of X, then p ∈ X ⇒ p ∈ (A ∩ B)'
⇒ p ∉ (A ∩ B)
⇒ p ∉ A or p ∉ B
⇒ p ∈ A' or p ∈ B'
⇒ p ∈ A' ∪ B'
⇒ p ∈ Y

∴ X ⊂ Y --------------(i)

Again, let q be any element of Y, then q ∈ Y ⇒ q ∈ A' ∪ B'

⇒ q ∈ A' or q ∈ B'
⇒ q ∉ A and q ∉ B
⇒ q ∉ (A ∩ B)
⇒ q ∈ (A ∩ B)'
⇒ q ∈ X

∴ Y ⊂ X --------------(ii)

From (i) and (ii) X = Y

(A ∩ B)' = A' ∪ B'

Proof Using Venn Diagram

Venn Diagram for (A ∩ B)'

Venn Diagram for (A ∩ B)'

Venn diagram for A' ∪ B'

Venn diagram for A' ∪ B'

From both diagrams, we can clearly say

(A ∩ B)' = A' ∪ B'

That is the Second De Morgan's Law.

De Morgan's Law in Boolean Algebra

De Morgan's Law Boolean Algebra defines the relation between the OR, AND, and the complements of variables, and is given for both the complement of AND and OR of two values. In Boolean Algebra there are two De Morgan's Laws that are:

  • First De Morgan's Law
  • Second De Morgan's Law

Let's understand these laws in detail as below:

First De Morgan's Law in Boolean Algebra

First De Morgan's law states that "The complement of OR of two or more variables is equal to the AND of the complement of each variable."

Let A and B be two variables, then mathematically First De Morgan's Law is given as:

(A + B)' = A' . B'

Where 

  • + represents the OR operator between variables,
  • . represents AND operator between variables, and 
  • ' represents complement operation on the variable.

First De Morgan's Law Logic Gates

In context to logic gates and Boolean Algebra, De Morgan's Law states that "Both the logic gate circuits i.e., NOT gate is added to the output of OR gate, and NOT gate is added to the input of AND gate, are equivalent. These two logic gate circuits are given as follows:

l2

First De Morgan's Law Truth Table

The truth table for first De Morgan's Law is given as follows:

A

B

A + B

(A + B)'

A'

B'

A'. B'

0

0

0

1

1

1

1

0

1

1

0

1

0

0

1

0

1

0

0

1

0

1

1

1

0

0

0

0

Second De Morgan's Law in Boolean Algebra

Second De Morgan's law states that "The complement of AND of two or more variables is equal to the OR of the complement of each variable."

Let A and B be two variables, then mathematically Second De Morgan's Law is given as:

(A . B)' = A' + B'

Where 

  • + represents the OR operator between variables,
  • . represents AND operator between variables, and 
  • ' represents complement operation on variable.

Second De Morgan's Law Logic Gates

In context to logic gates and Boolean Algebra, De Morgan's Law states that "Both the logic gate circuits i.e., NOT gate is added to the output of AND gate, and NOT gate is added to the input of OR gate, are equivalent. These two logic gate circuits are given as follows:

Untitled-Diagram-(1)

Second De Morgan's Law Truth Table

The truth table for the second De Morgan's Law is given as follows:

A

B

A . B

(A. B)'

A'

B'

A' + B'

0

0

0

1

1

1

1

0

1

0

1

1

0

1

1

0

0

1

0

1

1

1

1

1

0

0

0

0

De Morgan's Law of Logic

In De Morgan's law for logic the below propositions are tautology:

∼ (a ∧ b) ≡ ∼ a ∨ ∼ b

∼ (a ∨ b) ≡ ∼ a ∧ ∼ b

Where,

  • ∧ represents the conjunction of statements,
  • ∨ represents the disjunction of statements,
  • ~ represents the negation of a statement, and 
  • ≡ represents the equivalence of statements.

De Morgan's Law Formula

Let's compile all the formulas for De Morgan's Law in the following list.

For set theory:

  • (A ∪ B)' = A' ∩ B'
  • (A ∩ B)' = A' ∪ B'

For Boolean Algebra:

  • (A + B)' = A' . B'
  • (A . B)' = A' + B'

For Logic:

  • ∼ (a ∧ b) ≡ ∼ a ∨ ∼ b
  • ∼ (a ∨ b) ≡ ∼ a ∧ ∼ b

De Morgan's Law Practical Examples

Example 1: Pizza Toppings

Imagine you're at a pizza party, and you're told you can choose any toppings except for both mushrooms and olives together.

  • Using De Morgan's Law: This means if you don't want both mushrooms and olives (Not (Mushrooms and Olives)), you can either not have mushrooms (Not Mushrooms) or not have olives (Not Olives) on your pizza. So, you could have a pizza with just mushrooms, just olives, or neither!

Example 2: Library Books

Your teacher says you cannot bring books about wizards or dragons into the classroom.

  • Using De Morgan's Law: This means if you're not allowed books about wizards or dragons (Not (Wizards or Dragons)), you can't bring books about wizards (Not Wizards) and you can't bring books about dragons (Not Dragons). So, books about space or animals are still okay!

Example 3: Playing Outside

Your mom says you can't play outside if it's raining and cold at the same time.

  • Using De Morgan's Law: This means if you're not going out because it's raining and cold (Not (Raining and Cold)), you wouldn't go out if it's just raining (Not Raining) or just cold (Not Cold). But if it's sunny and warm, you're good to go!

Example 4: Choosing a Movie

Your friend says they don't want to watch a movie that is scary or boring.

  • Using De Morgan's Law: This means if your friend doesn't want a movie that's scary or boring (Not (Scary or Boring)), they don't want a scary movie (Not Scary) and they don't want a boring movie (Not Boring). So, a funny or exciting movie would be perfect!

Solved Question on De Morgan's Law

Question 1: Given that U = {2, 3, 7, 8, 9}, A = {2, 7} and B = {2, 3, 9}. Prove De Morgan's Second Law.

Solution:

U = {2, 3, 7, 8, 9}, A = {2, 7} and B = {2, 3, 9}
To Prove: (A ∩ B)' = A' ∪ B'
(A ∩ B) = {2}
(A ∩ B)' = U - (A ∩ B) = {2, 3, 7, 8, 9} - {2}
(A ∩ B)' = {3, 7, 8, 9}
A' = U - A = {2, 3, 7, 8, 9} - {2, 7}
A' = {3, 8, 9}
B' = U - B = {2, 3, 7, 8, 9} - {2, 3, 9}
B' = {7, 8}
A' ∪ B' = {3, 8, 9} ∪ {7, 8}
A' ∪ B' = {3, 7, 8, 9}

(A ∩ B)' = A' ∪ B'

Question 2: Given that U = {1, 4, 6, 8, 9}, A = {1, 9} and B = {4, 6, 9}. Prove De Morgan's First Law.

Solution:

U = {1, 4, 6, 8, 9}, A = {1, 9} and B = {4, 6, 9}
To Prove: (A ∪ B)' = A' ∩ B'
(A ∪ B) = {1, 4, 6, 9}
(A ∪ B)' = U - (A ∪ B) = {1, 4, 6, 8, 9} - {1, 4, 6, 9}
(A ∪ B)' = {8}
A' = U - A = {1, 4, 6, 8, 9} - {1, 9}
A' = {4, 6, 8}
B' = U - B = {1, 4, 6, 8, 9} - {4, 6, 9}
B' = {1, 8}
A' ∩ B' = {4, 6, 8} ∩ {1, 8}
A' ∩ B' = {8}
(A ∪ B)' = A' ∩ B'

Hence Proved

Question 3: Simplify the Boolean Expression: Y = [(A + B).C]'

Solution:

Y = [(A + B).C]'
Applying De Morgan's law (A . B)' = A' + B'
Y = (A + B)' + C'
Applying De Morgan's law (A + B)' = A'. B'
Y = A'. B' + C'

Question 4: Simplify the Boolean Expression: X = [(A + B)' + C]'

Solution:

X = [(A + B)' + C]'
Applying De Morgan's law (A + B)' = A'. B'
X = [(A + B)']' . C'
X = (A + B). C'

Check this sources for more:

Topic for InterlinkingRelated to
Boolean AlgebraDe Morgan's Law Boolean Algebra
Set TheoryDe Morgan's Law in Set Theory
Logical GatesDe Morgan's Law of Logic
Discrete MathematicsDe Morgan's Law Discrete Math
Java Programming ExamplesDe Morgan's Law Java

Showcase Examples of De Morgan's Law

ContextExample
Logic PuzzlesPuzzle: If it is not true that "It is raining and cold," what can we infer? Application of De Morgan's Law: We can infer that "It is not raining or it is not cold." This uses De Morgan's Law to simplify the negation of a conjunction into a disjunction.
ProgrammingScenario: Checking if a number is neither positive nor even in a programming language. Code Snippet (Pseudocode): if !(number > 0 and number % 2 == 0) can be simplified using De Morgan's Law to if (number <= 0 or number % 2 != 0). This demonstrates how De Morgan's Law helps in simplifying conditional statements.
Mathematical ProofsStatement: Prove that the complement of the intersection of two sets A and B is equal to the union of their complements. Application of De Morgan's Law: According to De Morgan's Law, (A ∩ B)' = A' ∪ B'. This shows how De Morgan's Law is used to simplify expressions in set theory.

Logic Applications of De Morgan's Law

Application AreaDescription
Logical ReasoningIn logical puzzles or arguments, De Morgan's Law helps simplify complex negations. For instance, negating "All apples are red" to "Not all apples are red" implies "Some apples are not red."
Computer ScienceDe Morgan's Law is crucial in optimizing conditional statements in programming. It allows programmers to simplify complex logical conditions, making code more efficient and readable.
Electronic Circuit DesignIn digital electronics, De Morgan's Law is used to design and simplify circuits. For example, it helps in converting AND gates into OR gates (and vice versa) using NOT gates, facilitating the creation of more efficient circuit layouts.

Next Article
De Morgan's Law - Theorem, Proofs, Formula & Examples

A

aayushi2402
Improve
Article Tags :
  • Mathematics
  • School Learning
  • Class 11
  • Maths-Class-11
  • Math-Concepts

Similar Reads

    Set Theory
    Set theory is a branch of mathematics that deals with collections of objects, called sets. A set is simply a collection of distinct elements, such as numbers, letters, or even everyday objects, that share a common property or rule.Example of SetsSome examples of sets include:A set of fruits: {apple,
    3 min read
    Set Theory Formulas
    In mathematics, a set is simply a collection of well-defined individual objects that form a group. A set can contain any group of items, such as a set of numbers, a day of the week, or a vehicle. Each element of the set is called an element of the set.Example: A = { 2, 4, 6, 8 }. A is a set and 2, 4
    8 min read

    Representation of Set

    Representation of a Set
    Sets are defined as collections of well-defined data. In Math, a Set is a tool that helps to classify and collect data belonging to the same category. Even though the elements used in sets are all different from each other, they are all similar as they belong to one group. For instance, a set of dif
    8 min read
    Set-Builder Notation
    Set-builder Notation is a type of mathematical notation used to describe sets by naming their components or highlighting the requirements that each member of the set must meet. Sets are written in the form of {y | (properties of y)} OR {y : (properties of y)} in the set-builder notation, where the c
    11 min read

    Types of Set

    Types Of Sets
    In mathematics, a set is defined as a well-defined collection of distinct elements that share a common property. These elements— like numbers, letters, or even other sets are listed in curly brackets "{ }" and represented by capital letters. For example, a set can include days of the week. The diffe
    13 min read
    Empty Set
    Empty Sets are sets with no items or elements in them. They are also called null sets. The symbol (phi) ∅represents the empty set and is written as ∅ = { }. It is also known as a void set or a null set. When compared to other sets, empty sets are seen to be distinctive.Empty sets are used to simplif
    10 min read
    Disjoint Sets
    Disjoint Sets are one of the types of many pair of sets, which are used in Set Theory, other than this other types are equivalent sets, equal sets, etc. Set Theory is the branch of mathematics that deals with the collection of objects and generalized various properties for these collections of objec
    8 min read
    Finite Sets
    Finite set is a collection of finite, well-defined elements. For better understanding, imagine you have a bunch of your favourite toys or snacks. You know exactly how many you have, that's the idea of a finite set in math. A finite set is a way to discuss collections of things you can count. In this
    10 min read
    Universal Sets
    Universal Set is a set that has all the elements associated with a given set, without any repetition. Suppose we have two sets P = {1, 3, 5} and Q = {2, 4, 6} then the universal set of P and Q is U = {1, 2, 3, 4, 5, 6}. We generally use U to denote universal sets. Universal Set is a type of set that
    6 min read
    Subsets in Maths
    Subsets in Maths are a core concept in the study of Set Theory. It can be defined as a group of elements, objects, or members enclosed in curly braces, such as {x, y, z} is called a Set, where each member of the set is unique and is taken from another set called the Parent Set.This article explores
    12 min read

    Operation on Sets

    Set Operations
    A set is simply a collection of distinct objects. These objects can be numbers, letters, or even people—anything! We denote a set using curly brackets.For example: A = {1, 2, 3}Set Operations can be defined as the operations performed on two or more sets to obtain a single set containing a combinati
    10 min read
    Union of Sets
    Union of two sets means finding a set containing all the values in both sets. It is denoted using the symbol '∪' and is read as the union. Example 1:If A = {1, 3. 5. 7} and B = {1, 2, 3} then A∪B is read as A union B and its value is,A∪B = {1, 2, 3, 5, 7}Example 2:If A = {1, 3. 5.7} and B = {2, 4} t
    12 min read
    Intersection of Sets
    Intersection of Sets is the operation in set theory and is applied between two or more sets. It result in the output as all the elements which are common in all the sets under consideration. For example, The  intersection of sets A and B is the set of all elements which are common to both A and B.In
    11 min read
    Difference of Sets
    Difference of Sets is the operation defined on sets, just like we can perform arithmetic operations on numbers in mathematics. Other than the difference, we can also perform the union and intersection of sets for any given set. These operations have a lot of important applications in mathematical pr
    10 min read
    Complement of a Set
    In mathematics, a set is a collection or grouping of well-defined objects. All such objects, when grouped in a set, are called elements. Sets are represented by capital letter symbols, and the elements are placed together in a curly bracket {}.For example, if W is the set of whole numbers, then W =
    10 min read
    Cartesian Product of Sets
    The term 'product' mathematically refers to the result obtained when two or more values are multiplied together. For example, 45 is the product of 9 and 5.To understand the Cartesian product of sets, one must first be familiar with basic set operations such as union and intersection, which are appli
    7 min read

    Application of Set

    De Morgan's Law - Theorem, Proofs, Formula & Examples
    De Morgan's law is the law that gives the relation between union, intersection, and complements in set theory. In Boolean algebra, it gives the relation between AND, OR, and complements of the variable, and in logic, it gives the relation between AND, OR, or Negation of the statement. With the help
    13 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences