De Morgan calculator
Negate AND/OR expressions, push NOT to individual variables, and verify the equivalent form with a complete truth table.
Notation note: This tool uses two-valued Boolean logic: every variable is true or false. Programming languages, databases and hardware description languages can introduce short-circuit evaluation, null/unknown values or operator rules that require additional care.
What is a De Morgan calculator?
A De Morgan calculator rewrites the negation of an AND/OR expression without changing its truth value. It moves NOT through a group, switches AND to OR or OR to AND, and negates every operand. This page also produces a truth table so the original negation and transformed expression can be checked row by row.
If you searched for a “Morgan calculator,” the standard mathematical name is De Morgan’s Law calculator, after the logician Augustus De Morgan.
De Morgan’s laws for Boolean logic
“Not both” means at least one operand is false.
“Neither” means both operands are false.
The same transformation extends to more operands and nested groups. Each time a negation crosses an AND/OR operator, the operator changes and the negation continues inward.
How the expression transformer works
A restricted parser accepts variables, constants, NOT, AND, OR and parentheses. It does not execute the text as code.
NOT has the highest precedence, then AND, then OR. Parentheses override that order.
At every AND/OR node, De Morgan’s law flips the operator and passes negation to both branches. Double negations cancel.
The tool evaluates both forms for every possible variable assignment and reports whether all rows match.
De Morgan transformation examples
The AND flips to OR and both inputs are negated.
Every OR becomes AND under the outer negation.
The outer AND flips first; the nested OR flips when its negation moves inward.
The double negation on A cancels.
Logic, programming, gates and sets
!(isAdmin && isActive)!isAdmin || !isActiveThese are equivalent in ordinary two-valued Boolean logic.
A negated AND is a NAND operation; De Morgan’s law shows its equivalent OR gate with inverted inputs. The dual relationship applies to NOR.
(A ∪ B)ᶜ = Aᶜ ∩ Bᶜ(A ∩ B)ᶜ = Aᶜ ∪ BᶜUnion corresponds to OR, intersection to AND, and complement to NOT.
Negated filters can be rewritten so exclusions apply to individual conditions, but systems with NULL or unknown values need their own semantics.
The operator must change
Negating the inputs without swapping AND to OR is not equivalent.
Negating an OR group requires AND between the negated inputs.
Both actions are required at each crossed AND or OR.
Sources supporting the method
De Morgan calculator FAQs
What are De Morgan’s two laws?
The negation of A AND B is equivalent to NOT A OR NOT B. The negation of A OR B is equivalent to NOT A AND NOT B.
How do I use this De Morgan calculator?
Use the explorer for the two basic laws, or choose the expression transformer, enter a Boolean expression, and calculate. The tool negates the whole expression, produces negation normal form and builds a truth table.
Which Boolean operators can I enter?
Use !, ~ or ¬ for NOT; &, * or ∧ for AND; and |, + or ∨ for OR. Parentheses and Boolean constants 0 and 1 are also supported.
What is negation normal form?
Negation normal form, or NNF, uses only AND, OR and NOT, with every NOT applied directly to a variable or constant rather than to a grouped expression.
Why does AND change to OR?
For NOT(A AND B) to be true, at least one of A or B must be false. That condition is expressed as NOT A OR NOT B.
Why does OR change to AND?
For NOT(A OR B) to be true, both A and B must be false. That condition is expressed as NOT A AND NOT B.
Can the calculator handle nested parentheses?
Yes. It parses nested groups and recursively pushes the outer negation inward, switching every crossed AND or OR and cancelling double negations.
How many variables are supported?
The truth-table generator supports up to six distinct single-letter variables, producing at most 64 input rows.
Does the calculator execute my expression as code?
No. A restricted purpose-built parser reads only the documented Boolean tokens. The plugin does not use eval or execute the entered expression.
How are De Morgan’s laws used in programming?
They help rewrite negated compound conditions. For example, NOT(A AND B) can be expressed as NOT A OR NOT B. Language-specific short-circuit, null and type rules still apply.
Do De Morgan’s laws apply to sets?
Yes. The complement of a union equals the intersection of the complements, and the complement of an intersection equals the union of the complements.
Are my Boolean expressions stored?
No. Parsing, transformation and truth-table generation happen locally in the browser, and the plugin does not transmit or store the entered expression.