A rule of boolean logic that describes how negation distributes across grouped conditions. In query languages, it changes the way combined expressions are evaluated, which can materially alter results when parentheses and not equal operators are used together.
What De Morgan's Law Changes in Boolean Logic
De Morgan's Law matters because it preserves meaning while changing structure. A negated grouped condition can be rewritten as separate negations joined by the opposite operator, which is especially useful when you need to simplify expressions, verify logic, or translate a rule into a query language without changing its intent.
This is not just algebraic neatness. In security tooling, filtering, search, and query evaluation, the placement of parentheses and negation can determine whether you match a narrow set of records or a much broader one. The law gives you a reliable way to reason about those transformations before they become production logic.
How Negation Moves Across Groups
The core idea is that negating a grouped expression flips both the operator and each condition inside the group. For example, NOT (A AND B) becomes (NOT A) OR (NOT B), and NOT (A OR B) becomes (NOT A) AND (NOT B). The rule applies symmetrically, so the rewritten form is logically equivalent to the original.
That equivalence is what makes the law so powerful. It lets you push a negation inward until each atomic condition is explicit, which often makes the expression easier to test, optimize, or compare with another query. In practice, that can help when a language has strict operator precedence or when parentheses are the only thing preventing a different result set.
Why It Matters in Query Evaluation
Query languages, search engines, and rule engines often evaluate boolean expressions exactly as written, so a small change in grouping can materially alter results. De Morgan's Law is the mental model that helps you anticipate that shift, especially when combining exclusion logic with multiple conditions.
It is particularly useful when you are trying to express "not this combined case" rather than "this and that are both false." Those are not always equivalent if the expression is written casually. Using the law forces the negation to land on the actual terms, which reduces ambiguity and makes the logic easier to audit.
In security contexts, that precision can matter in allowlists, blocklists, detection queries, and policy conditions. A mistaken rewrite can broaden or narrow matches in ways that affect investigation results, access decisions, or alert volume.
Common Pitfalls and Safer Reasoning
The most common mistake is treating NOT as if it only applies to the nearest word rather than to the entire parenthesised group. Another error is assuming that swapping AND for OR is enough, while forgetting that each inner condition must also be negated. Both mistakes can produce logic that looks plausible but evaluates differently.
A safer habit is to read the expression from the inside out. First identify the full scope of the parentheses, then apply the negation to the whole group, and only then rewrite the internal operators. That discipline helps when expressions are nested or when a query language has operator precedence rules that are easy to misread.
Risk and Threat Considerations
Logical rewrites are a subtle source of security exposure because they can silently change who or what matches a rule. In access control, detection, or filtering logic, a misplaced negation can turn a narrow exclusion into a broad allowance, or hide records that should have been included for review.
Failure mechanism: An operator precedence mistake or an incomplete De Morgan rewrite changes the set of evaluated conditions, so the system enforces a different decision than the author intended.
Impact: The result can be missed detections, overbroad access, false exclusions, or incorrect search results, all of which are hard to spot if the rewritten expression still looks syntactically valid.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V15 — Secure Coding and Architecture | Boolean logic correctness is central to secure rule and query design. |
| Recommendation — Review complex boolean expressions for logical equivalence before deploying security-sensitive code. | ||
| NIST SP 800-53 Rev 5 | AC-6 — Least Privilege | Incorrect negation can broaden or narrow access decisions in authorization logic. |
| Recommendation — Validate access rules so negated conditions do not create unintended privilege. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Secure application logic includes correct handling of conditional and decision logic. |
| Recommendation — Test application filters and rules for logic errors that change enforcement outcomes. | ||
Practitioner Guidance
What to watch for: Use De Morgan's Law as a review check whenever a query or policy uses both negation and grouped conditions. If the logic is security-sensitive, test the original and rewritten forms against known examples so you can confirm that the result set is exactly what you expect.
Governance implication: Teams that own filters, detections, or policy rules should standardise how complex boolean expressions are written and reviewed, because the correctness of the logic is often more important than the syntax style itself.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 30, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org