TutreNews Learn

Boolean logic

De Morgan's laws

Goal: Negate AND/OR expressions correctly · 9 min

How do you negate a combined condition? De Morgan's laws:

  • NOT (A AND B) = (NOT A) OR (NOT B)
  • NOT (A OR B) = (NOT A) AND (NOT B)

"Negate each part and swap AND ↔ OR."

Everyday check: "not (rainy and cold)" means "not rainy, or not cold" — a warm rainy day qualifies.

In code this matters constantly: the opposite of age >= 18 && hasTicket is age < 18 || !hasTicket. Writing age < 18 && !hasTicket is a classic bug.

Worked example: Proving the first law

  1. NOT (A AND B): 1, 1, 1, 0 (rows 00, 01, 10, 11).
  2. (NOT A) OR (NOT B): 1, 1, 1, 0.
  3. Identical columns → equivalent.