Calculate Using De Morgan\’s Law






De Morgan’s Law Calculator – Understand Boolean Algebra Equivalences


De Morgan’s Law Calculator

Unlock the power of Boolean algebra with our interactive De Morgan’s Law calculator.
Easily verify the equivalences for logical expressions, understand how negation distributes
over conjunction (AND) and disjunction (OR), and see the results in a clear truth table and dynamic chart.
Perfect for students, engineers, and programmers working with digital logic and propositional logic.

De Morgan’s Law Calculator




Select the truth value for variable A.



Select the truth value for variable B.


Select which of De Morgan’s Laws you want to demonstrate.


Calculation Results

Equivalence Verified:

Intermediate Value 1:

Intermediate Value 2:

Intermediate Value 3:


Truth Table for De Morgan’s Law
A B LHS Expression RHS Expression Equivalence

Visualizing De Morgan’s Law

What is De Morgan’s Law?

De Morgan’s Law, or De Morgan’s theorems, are a pair of transformation rules in Boolean algebra that relate the conjunction and disjunction of propositions through negation. Named after Augustus De Morgan, a British mathematician, these laws are fundamental to understanding and simplifying logical expressions, set theory, and digital circuit design. They provide a way to express the negation of a conjunction (AND) or a disjunction (OR) in terms of the negations of the individual components.

In simple terms, De Morgan’s Law states that:

  • The negation of a conjunction (NOT (A AND B)) is equivalent to the disjunction of the negations ( (NOT A) OR (NOT B) ).
  • The negation of a disjunction (NOT (A OR B)) is equivalent to the conjunction of the negations ( (NOT A) AND (NOT B) ).

Who Should Use De Morgan’s Law?

De Morgan’s Law is a cornerstone for anyone working with logic and computation:

  • Computer Scientists & Programmers: Essential for simplifying complex conditional statements, optimizing code, and understanding logical operations in programming languages.
  • Electrical Engineers & Digital Designers: Crucial for designing and simplifying logic circuits, minimizing the number of gates, and ensuring correct circuit behavior.
  • Mathematicians & Logicians: Fundamental for propositional logic, predicate logic, and set theory, providing tools for proofs and derivations.
  • Students: A core concept taught in introductory courses on discrete mathematics, computer science, and digital electronics.

Common Misconceptions about De Morgan’s Law

Despite its simplicity, several misconceptions can arise when applying De Morgan’s Law:

  • Distributing Negation Incorrectly: A common mistake is to simply distribute the NOT operator without changing the inner operator. For example, thinking NOT(A AND B) is (NOT A) AND (NOT B), which is incorrect. The AND must become OR, and vice-versa.
  • Forgetting to Negate All Terms: Sometimes, one of the variables is negated, but the other is overlooked. Both A and B must be negated when applying De Morgan’s Law.
  • Applying to Non-Boolean Contexts: While the principles can be analogous in other areas (like set theory with complements and unions/intersections), directly applying the Boolean operators to non-Boolean contexts without proper translation can lead to errors.
  • Confusion with Implication: De Morgan’s Law deals with AND/OR and NOT. It’s distinct from rules involving implication (IF-THEN statements), though it can be used in conjunction with other logical equivalences to simplify expressions containing implications.

De Morgan’s Law Formula and Mathematical Explanation

De Morgan’s Law consists of two primary equivalences. Let A and B be logical propositions that can be either True (1) or False (0).

Law 1: Negation of Conjunction

The first law states that the negation of a conjunction (AND operation) is equivalent to the disjunction (OR operation) of the negations of the individual propositions.

Formula: NOT (A AND B) ≡ (NOT A) OR (NOT B)

Step-by-step Derivation (using truth values):

  1. Evaluate (A AND B): This expression is True only if both A and B are True. Otherwise, it’s False.
  2. Evaluate NOT (A AND B): This is the negation of the previous result. If (A AND B) is True, NOT (A AND B) is False. If (A AND B) is False, NOT (A AND B) is True.
  3. Evaluate (NOT A): This is the negation of A.
  4. Evaluate (NOT B): This is the negation of B.
  5. Evaluate (NOT A) OR (NOT B): This expression is True if (NOT A) is True, or (NOT B) is True, or both are True. It is False only if both (NOT A) and (NOT B) are False.
  6. Comparison: By comparing the truth values of NOT (A AND B) and (NOT A) OR (NOT B) for all possible combinations of A and B, we find they are identical, thus proving the equivalence.

Law 2: Negation of Disjunction

The second law states that the negation of a disjunction (OR operation) is equivalent to the conjunction (AND operation) of the negations of the individual propositions.

Formula: NOT (A OR B) ≡ (NOT A) AND (NOT B)

Step-by-step Derivation (using truth values):

  1. Evaluate (A OR B): This expression is True if A is True, or B is True, or both are True. It is False only if both A and B are False.
  2. Evaluate NOT (A OR B): This is the negation of the previous result. If (A OR B) is True, NOT (A OR B) is False. If (A OR B) is False, NOT (A OR B) is True.
  3. Evaluate (NOT A): This is the negation of A.
  4. Evaluate (NOT B): This is the negation of B.
  5. Evaluate (NOT A) AND (NOT B): This expression is True only if both (NOT A) and (NOT B) are True. Otherwise, it’s False.
  6. Comparison: By comparing the truth values of NOT (A OR B) and (NOT A) AND (NOT B) for all possible combinations of A and B, we find they are identical, thus proving the equivalence.

Variable Explanations

Variable Meaning Unit Typical Range
A Logical Proposition A Boolean (True/False or 1/0) {True, False} or {1, 0}
B Logical Proposition B Boolean (True/False or 1/0) {True, False} or {1, 0}
NOT Logical Negation (inverts truth value) Operator N/A
AND Logical Conjunction (True if both are True) Operator N/A
OR Logical Disjunction (True if at least one is True) Operator N/A
Logical Equivalence (means “is equivalent to”) Symbol N/A

Practical Examples (Real-World Use Cases)

Example 1: Conditional Logic in Programming

Imagine you’re writing code where a certain action should NOT happen if two conditions are met simultaneously.

Scenario: A user should NOT be granted access if they are both ‘unverified’ AND ‘have an expired subscription’.

  • Let A = “User is unverified”
  • Let B = “User has an expired subscription”

The original condition for denying access is: NOT (A AND B).

Using De Morgan’s Law (Law 1), this is equivalent to: (NOT A) OR (NOT B).

Interpretation: The user will be granted access if they are NOT unverified (i.e., verified) OR if they do NOT have an expired subscription (i.e., their subscription is active). This simplification can make code more readable or easier to optimize, especially in complex nested conditions.

Calculator Input:

  • Logical Variable A (User is unverified): True (1)
  • Logical Variable B (User has an expired subscription): True (1)
  • Choose De Morgan’s Law: Law 1: NOT(A AND B) ≡ (NOT A) OR (NOT B)

Calculator Output (Expected):

  • Primary Result: NOT (True AND True) ≡ (NOT True) OR (NOT True) → False ≡ False. Equivalence Verified!
  • Intermediate 1: (A AND B) = True
  • Intermediate 2: (NOT A) = False
  • Intermediate 3: (NOT B) = False

This shows that if both conditions are true, the overall condition NOT (A AND B) is False, meaning access is denied. The equivalent (NOT A) OR (NOT B) also evaluates to False (False OR False is False), confirming the law.

Example 2: Digital Logic Circuit Design

Consider a safety system where an alarm should trigger if a specific set of conditions is NOT met.

Scenario: An alarm should sound if the system is NOT in a “safe state”. A “safe state” is defined as “Temperature is within range” OR “Pressure is stable”.

  • Let A = “Temperature is within range”
  • Let B = “Pressure is stable”

The condition for the alarm to sound is: NOT (A OR B).

Using De Morgan’s Law (Law 2), this is equivalent to: (NOT A) AND (NOT B).

Interpretation: The alarm will sound if the Temperature is NOT within range (i.e., out of range) AND the Pressure is NOT stable (i.e., unstable). This transformation allows engineers to design circuits using different combinations of logic gates (e.g., using only NAND or NOR gates) which can sometimes be more efficient or cost-effective.

Calculator Input:

  • Logical Variable A (Temperature within range): False (0)
  • Logical Variable B (Pressure stable): False (0)
  • Choose De Morgan’s Law: Law 2: NOT(A OR B) ≡ (NOT A) AND (NOT B)

Calculator Output (Expected):

  • Primary Result: NOT (False OR False) ≡ (NOT False) AND (NOT False) → True ≡ True. Equivalence Verified!
  • Intermediate 1: (A OR B) = False
  • Intermediate 2: (NOT A) = True
  • Intermediate 3: (NOT B) = True

Here, if both conditions A and B are false, the alarm condition NOT (A OR B) is True, meaning the alarm sounds. The equivalent (NOT A) AND (NOT B) also evaluates to True (True AND True is True), confirming De Morgan’s Law.

How to Use This De Morgan’s Law Calculator

Our De Morgan’s Law calculator is designed for ease of use, allowing you to quickly verify logical equivalences and deepen your understanding of Boolean algebra. Follow these simple steps:

Step-by-Step Instructions:

  1. Select Logical Variable A: Choose ‘True (1)’ or ‘False (0)’ from the dropdown menu for the first proposition, A.
  2. Select Logical Variable B: Choose ‘True (1)’ or ‘False (0)’ from the dropdown menu for the second proposition, B.
  3. Choose De Morgan’s Law: Select which of the two De Morgan’s Laws you wish to demonstrate.
    • Law 1: NOT(A AND B) ≡ (NOT A) OR (NOT B)
    • Law 2: NOT(A OR B) ≡ (NOT A) AND (NOT B)
  4. Calculate: The results will update in real-time as you change the inputs. You can also click the “Calculate De Morgan’s Law” button to manually trigger the calculation.
  5. Reset: Click the “Reset” button to clear all inputs and revert to default values.
  6. Copy Results: Use the “Copy Results” button to copy the main result, intermediate values, and key assumptions to your clipboard for easy sharing or documentation.

How to Read Results:

  • Primary Result: This prominently displayed result confirms whether the chosen De Morgan’s Law holds true for your selected input values. It will show the evaluation of both sides of the equivalence and state “Equivalence Verified!” if they match.
  • Intermediate Values: These show the truth values of the sub-expressions involved in the calculation, helping you trace the logic step-by-step. For example, you’ll see the value of (A AND B) or (NOT A).
  • Formula Explanation: A brief textual explanation of the specific De Morgan’s Law being demonstrated is provided.
  • Truth Table: A comprehensive truth table is generated below the results, showing the truth values for A, B, the Left-Hand Side (LHS) expression, the Right-Hand Side (RHS) expression, and the final equivalence for all four possible combinations of A and B. This is crucial for understanding why De Morgan’s Law always holds.
  • Visualizing De Morgan’s Law Chart: A dynamic bar chart visually represents the truth values of the LHS and RHS expressions across all input combinations, offering an intuitive way to see their equivalence.

Decision-Making Guidance:

This calculator serves as an excellent educational tool. Use it to:

  • Verify your manual calculations: If you’re solving problems involving De Morgan’s Law, use the calculator to check your answers.
  • Understand the impact of negation: Observe how the NOT operator transforms conjunctions into disjunctions and vice-versa.
  • Explore different scenarios: Test all four combinations of True/False for A and B to build a complete understanding of the truth table.
  • Simplify complex expressions: While the calculator handles two variables, the principles of De Morgan’s Law can be applied iteratively to simplify more complex logical expressions in programming or circuit design.

Key Factors That Affect De Morgan’s Law Results

De Morgan’s Law itself is a fundamental logical equivalence, meaning its “results” (the equivalence itself) are always true. However, the *application* and *interpretation* of De Morgan’s Law in practical scenarios can be influenced by several factors. These factors primarily relate to how the logical propositions are defined and how the resulting expressions are used.

  • Definition of Logical Propositions (A and B): The clarity and precision with which A and B are defined are paramount. Ambiguous definitions can lead to incorrect initial truth assignments, which will propagate errors through any logical calculation, including those using De Morgan’s Law.
  • Correct Application of Logical Operators: Ensuring that AND, OR, and NOT operators are used correctly according to their definitions is critical. A misunderstanding of these basic operators will lead to incorrect evaluations of both sides of De Morgan’s Law.
  • Context of Application: Whether De Morgan’s Law is applied in programming, digital logic, or set theory, the specific rules and conventions of that domain must be respected. For instance, in programming, ‘AND’ might be `&&` and ‘OR’ might be `||`, and short-circuiting behavior could be a factor in evaluation order, though not in the logical equivalence itself.
  • Number of Variables and Complexity: While De Morgan’s Law is typically shown with two variables, it can be extended to multiple variables (e.g., NOT(A AND B AND C) ≡ (NOT A) OR (NOT B) OR (NOT C)). The complexity of the overall expression can make manual application prone to errors, highlighting the utility of systematic approaches or tools.
  • Interpretation of Truth Values: In some systems, ‘True’ might be represented by 1, and ‘False’ by 0. In others, it might be non-zero vs. zero, or specific keywords. Consistent interpretation of these truth values is essential for accurate results.
  • Potential for Human Error: Manual application of De Morgan’s Law, especially within larger logical expressions, is susceptible to human error, such as forgetting to flip an operator (AND to OR) or neglecting to negate a term. Calculators like this one help mitigate such errors.

Frequently Asked Questions (FAQ)

Q1: What is the main purpose of De Morgan’s Law?

A1: The main purpose of De Morgan’s Law is to provide equivalent expressions for the negation of conjunctions (AND) and disjunctions (OR). This allows for simplification of logical statements, transformation between different forms of logic gates in digital circuits, and clearer expression of conditions in programming.

Q2: Can De Morgan’s Law be applied to more than two variables?

A2: Yes, De Morgan’s Law can be extended to any number of variables. For example, NOT(A AND B AND C) is equivalent to (NOT A) OR (NOT B) OR (NOT C). Similarly, NOT(A OR B OR C) is equivalent to (NOT A) AND (NOT B) AND (NOT C).

Q3: How does De Morgan’s Law relate to set theory?

A3: In set theory, De Morgan’s Law has analogous forms:

  • The complement of the union of two sets is the intersection of their complements: (A ∪ B)’ = A’ ∩ B’
  • The complement of the intersection of two sets is the union of their complements: (A ∩ B)’ = A’ ∪ B’

Here, ‘complement’ is analogous to ‘NOT’, ‘union’ to ‘OR’, and ‘intersection’ to ‘AND’.

Q4: Is De Morgan’s Law used in everyday programming?

A4: Absolutely. Programmers frequently use De Morgan’s Law to simplify complex conditional statements, making code more readable, maintainable, and sometimes more efficient. For instance, `if (!(x > 5 && y < 10))` can be rewritten as `if (x <= 5 || y >= 10)`.

Q5: What are the limitations of De Morgan’s Law?

A5: De Morgan’s Law applies specifically to the negation of conjunctions and disjunctions. It does not directly apply to other logical operators like implication (IF-THEN) or exclusive OR (XOR) without first converting them into expressions involving AND, OR, and NOT.

Q6: Why is it important to understand De Morgan’s Law in digital logic design?

A6: In digital logic, De Morgan’s Law allows engineers to convert between different types of logic gates (e.g., converting an AND-NOT combination to an OR-NOT combination). This is crucial for optimizing circuit designs, reducing the number of gates, and ensuring that a circuit can be implemented using available gate types (e.g., using only NAND or NOR gates).

Q7: Can I use this calculator to solve complex logical expressions?

A7: This calculator is designed to demonstrate the fundamental two-variable De Morgan’s Law. For more complex expressions with multiple variables or nested operations, you would need to apply De Morgan’s Law iteratively or use a more advanced propositional logic solver. However, this tool provides a solid foundation for understanding the core principle.

Q8: What is the difference between logical equivalence and equality?

A8: Logical equivalence (≡) means that two logical expressions always have the same truth value for all possible assignments of their variables. Equality (=) typically refers to two expressions having the exact same structure or value in a mathematical sense. In Boolean algebra, when we say two expressions are equivalent, it implies they are interchangeable without changing the overall truth value of a larger statement.

Related Tools and Internal Resources

Expand your understanding of logic and computation with these related tools and resources:

© 2023 De Morgan’s Law Calculator. All rights reserved.



Leave a Comment