De Morgan’s Law Calculator | Easy Logical Equivalence Tool


De Morgan’s Law Calculator

An interactive tool to understand and verify the fundamental logical equivalences of De Morgan’s laws in boolean algebra.

Interactive Calculator

Select the truth values for propositions P and Q to see how De Morgan’s laws apply. The results will update automatically.



Equivalence Verified!

First Law: ¬(P ∧ Q) ⇔ (¬P) ∨ (¬Q)

¬(P ∧ Q)

(¬P) ∨ (¬Q)

Second Law: ¬(P ∨ Q) ⇔ (¬P) ∧ (¬Q)

¬(P ∨ Q)

(¬P) ∧ (¬Q)


What is De Morgan’s Law?

De Morgan’s laws are a pair of transformation rules in boolean algebra and formal logic. They describe how to distribute a negation operation over conjunction (AND) and disjunction (OR) operations. In simple terms, they provide a method for simplifying the negation of complex logical statements. The laws state that the negation of a conjunction is the disjunction of the negations, and the negation of a disjunction is the conjunction of the negations. These rules are fundamental in computer science, digital circuit design, and set theory.

Anyone working with logical statements, from software developers to circuit engineers and students of mathematics, can use this de morgan’s law calculator to verify their work. A common misunderstanding is confusing the AND and OR transformations. This calculator visually demonstrates the correct equivalences, clearing up any confusion.

De Morgan’s Law Formula and Explanation

The Formulas

The two laws are formally stated using logical notation. Let P and Q be two propositions:

  1. ¬(P ∧ Q) ⇔ (¬P) ∨ (¬Q)
    The negation of (P AND Q) is equivalent to (NOT P) OR (NOT Q).
  2. ¬(P ∨ Q) ⇔ (¬P) ∧ (¬Q)
    The negation of (P OR Q) is equivalent to (NOT P) AND (NOT Q).

Variables Explained

The symbols used in these formulas are standard in propositional logic.

Variable Meaning Unit Typical Range
P, Q Propositional Variables Truth Value True, False
Conjunction (AND) Logical Operator Returns True if both operands are True
Disjunction (OR) Logical Operator Returns True if at least one operand is True
¬ Negation (NOT) Logical Operator Inverts the truth value of its operand
Equivalence Logical Operator Means both sides always have the same truth value

This de morgan’s law calculator allows you to manipulate these variables and see the formulas in action.

Practical Examples

Example 1: Everyday Logic

Imagine a rule that says: “It is not the case that you can have both cake (P) and ice cream (Q).”

  • Statement: ¬(P ∧ Q)
  • Inputs: Let’s say you try to have both. P is True, Q is True.
  • De Morgan’s Law says this is equivalent to: (¬P) ∨ (¬Q), which means “You cannot have cake, OR you cannot have ice cream.”
  • Result: Since you tried to have both, the original statement is False (you broke the rule). The equivalent statement is also False, because you *did* have cake and you *did* have ice cream, so neither part of the “OR” statement is true. The equivalence holds.

Example 2: Computer Programming

In programming, you might write a condition like: if (!(isLoggedIn && isAdmin)) { ... }.

  • Statement: ¬(P ∧ Q), where P is `isLoggedIn` and Q is `isAdmin`.
  • Inputs: A user is logged in (P=True) but is not an admin (Q=False).
  • Calculation: `¬(True ∧ False)` becomes `¬(False)`, which is `True`. The code inside the `if` block will run.
  • Equivalent using De Morgan’s Law: `(!isLoggedIn || !isAdmin)`. With our inputs, this becomes `(¬True ∨ ¬False)`, which is `(False ∨ True)`, resulting in `True`.
  • Result: Both expressions yield the same result, proving their equivalence. Simplifying expressions using De Morgan’s law can make code more readable and sometimes more efficient. If you are a developer, using a boolean algebra calculator can be very helpful.

How to Use This De Morgan’s Law Calculator

Using this calculator is straightforward:

  1. Set Propositions: Use the checkboxes at the top to set the truth value for proposition P and proposition Q. Check the box to set a proposition to ‘True’, and uncheck it for ‘False’.
  2. Observe the Results: The results area automatically updates. It shows the evaluated truth value for both sides of each of De Morgan’s laws.
  3. Verify Equivalence: The primary result will confirm that both sides of the equation are equivalent for your chosen inputs. For example, `¬(P ∧ Q)` will always have the same truth value as `(¬P) ∨ (¬Q)`.
  4. Reset: Click the “Reset” button to return the checkboxes to their default state.

Full Truth Table

To fully prove De Morgan’s laws, we can use a truth table that shows all possible outcomes. This is what our de morgan’s law calculator computes internally.

Truth Table Demonstrating De Morgan’s Laws
P Q ¬(P ∧ Q) (¬P) ∨ (¬Q) ¬(P ∨ Q) (¬P) ∧ (¬Q)
True True False False False False
True False True True False False
False True True True False False
False False True True True True

As you can see, the columns for `¬(P ∧ Q)` and `(¬P) ∨ (¬Q)` are identical, as are the columns for `¬(P ∨ Q)` and `(¬P) ∧ (¬Q)`, proving the laws for all inputs.

Key Factors That Affect Logical Expressions

While the laws themselves are constant, their application can be influenced by several factors:

  • Operator Precedence: In complex expressions, the order of operations (precedence of AND, OR, NOT) is critical. Parentheses are used to enforce a specific order.
  • Boolean Algebra Simplification: De Morgan’s laws are often a key step in the larger process of simplifying a complex boolean expression down to its most minimal form. You may also want a truth table generator for more complex cases.
  • Application in Circuitry: In digital electronics, applying De Morgan’s law can allow engineers to build a circuit using only NAND gates or only NOR gates, which can be cheaper and more efficient.
  • Database Queries: When writing SQL or other database queries, complex `WHERE` clauses with multiple `AND`, `OR`, and `NOT` conditions can often be simplified for clarity and performance using these laws.
  • Formal Verification: In computer science, these laws are used in formal methods to prove that a piece of software or hardware behaves according to its specification.
  • Natural Language Ambiguity: When translating from English to a logical statement, it’s crucial to be precise. For example, “I want a topping that is not pepperoni and sausage” could be interpreted in two ways, and De Morgan’s law helps clarify the intended logic. For more complex logic, a propositional logic solver might be necessary.

Frequently Asked Questions (FAQ)

Is De Morgan’s Law always true?
Yes, within classical propositional logic and boolean algebra, De Morgan’s laws are tautologies, meaning they are universally true regardless of the truth values of the propositions involved.
What is the main purpose of De Morgan’s Law?
Its main purpose is simplification. It provides a way to transform a logical expression into an equivalent, often simpler or more convenient, form. This is especially useful for handling negations of complex statements.
How is this used in computer programming?
It’s used to simplify `if` conditions, `while` loops, and other logical checks. Applying the law can make code more readable and sometimes help the compiler optimize the program. For example, `! (a || b)` can be rewritten as `!a && !b`.
Can I apply this to more than two variables?
Yes. The law generalizes. For example, `¬(P ∧ Q ∧ R)` is equivalent to `(¬P) ∨ (¬Q) ∨ (¬R)`. The same applies to the OR version of the law.
What’s the connection to set theory?
In set theory, De Morgan’s laws relate the union and intersection of sets to their complements. The complement of the union of two sets is the intersection of their complements: (A ∪ B)’ = A’ ∩ B’. This directly mirrors the logical law and can be a good topic for a set theory calculator.
Who was De Morgan?
Augustus De Morgan was a 19th-century British mathematician and logician who formalized these laws, although the core ideas were known to earlier logicians like William of Ockham. His work was foundational to modern symbolic logic.
Does this calculator handle edge cases?
Yes. The calculator correctly evaluates the laws for all four possible combinations of truth values for the two propositions (True/True, True/False, False/True, False/False), which covers all edge cases.
How does this differ from the distributive law?
The distributive law relates AND and OR, such as `P ∧ (Q ∨ R) ⇔ (P ∧ Q) ∨ (P ∧ R)`. De Morgan’s laws are specifically about how negation interacts with AND and OR. Exploring the distributive law in boolean algebra can clarify the difference.

© 2026 Your Website Name. All Rights Reserved. This tool is for educational purposes.



Leave a Reply

Your email address will not be published. Required fields are marked *