De Morgan's Laws Boolean logic Solver
Simplify logic statements, check mathematical proofs, and evaluate digital truth tables in real-time.
Set Boolean Inputs
Proof Evaluation
Interactive Truth Table Reference
This table covers all possible states of variables $A$ and $B$. The active state is highlighted automatically based on the sliders above.
| A | B | ¬A | ¬B | A ∧ B | ¬(A ∧ B) | ¬A ∨ ¬B | ¬(A ∨ B) | ¬A ∧ ¬B |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 |
Deep Dive: De Morgan's Laws
Historical Background
**Augustus De Morgan** (1806–1871) was a British mathematician and logician. He formulated these laws which formally state how mathematical conjunctions ($\land$) and disjunctions ($\lor$) are related via negation ($\neg$).
Although these logical equivalents were known informally beforehand, De Morgan was the first to mathematically define them in the language of modern mathematical logic.
Logical Equivalences
The laws state that:
-
Negated Conjunction: The negation of an intersection is equal to the union of the individual negations.
!(A && B) == !A || !B -
Negated Disjunction: The negation of a union is equal to the intersection of the individual negations.
!(A || B) == !A && !B
Real-World Software Engineering Applications
De Morgan's laws are used constantly by developers to write cleaner, more performant software. Typical use cases include:
1. Simplifying If-Statements
Instead of writing complex conditions like `if (!(isUser && isActive))`, you can write the simplified equivalent: `if (!isUser || !isActive)`. This reduces cognitive load when reading complex logical statements.
2. SQL Database Queries
Database engines evaluate conditions faster when structured correctly. Converting a query like `WHERE NOT (status = 'pending' AND balance = 0)` to `WHERE status != 'pending' OR balance != 0` can sometimes allow the database query planner to leverage index maps better.
3. Hardware Logic Circuits
Digital chip designers use De Morgan's laws to build circuits using only one type of gate (e.g. NAND or NOR gates instead of AND/OR/NOT). This simplifies structural layout designs and lowers processor manufacturing costs.