Skip to main content
United StatesComputer ScienceSyllabus dot point

How do De Morgan's laws let you rewrite a negated boolean expression into an equivalent one?

Topic 3.6 Equivalent Boolean Expressions: apply De Morgan's laws and truth tables to produce equivalent boolean expressions and to simplify negations of compound conditions.

A focused answer to AP CSA Topic 3.6, covering De Morgan's laws for negating && and ||, using truth tables to prove equivalence, simplifying double negation, and rewriting conditions to remove a leading !, with a fully worked example.

Generated by Claude Opus 4.810 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this topic is asking
  2. What equivalence means
  3. De Morgan's laws
  4. Negating relational operators
  5. Double negation
  6. Proving equivalence with a truth table
  7. Try this

What this topic is asking

The College Board (Topic 3.6) wants you to recognize and produce equivalent boolean expressions: two expressions that give the same result for every combination of inputs. The headline tool is De Morgan's laws, which tell you how to push a ! (negation) inside a compound && or || expression. You should also be able to confirm equivalence with a truth table and to simplify a double negation. This is heavily tested in multiple choice, where you must spot the one equivalent rewrite among near-misses.

What equivalence means

De Morgan's laws

These let you remove an outer ! from a compound condition, which often reads more clearly. For instance, !(score >= 60 && attendance >= 80) becomes score < 60 || attendance < 80 ("failed on either count").

Negating relational operators

When you push a negation onto a single comparison, the operator flips to its opposite:

  • !(x > y) is x <= y
  • !(x >= y) is x < y
  • !(x < y) is x >= y
  • !(x <= y) is x > y
  • !(x == y) is x != y
  • !(x != y) is x == y

A frequent error is negating > to < (it is <=) or >= to <= (it is <). The boundary case is what changes: the negation of "greater than" includes equality.

Double negation

!!A simplifies to A: applying ! twice returns the original value. So !(!ready) is just ready. Watch for this hidden inside De Morgan rewrites.

Proving equivalence with a truth table

A truth table lists every combination of the input variables and the result of each expression. If the two result columns match in every row, the expressions are equivalent.

Try this

Q1. Rewrite !(p || q) without the leading !. [1 point]

  • Cue. !p && !q - De Morgan flips || to && and negates each operand.

Q2. Explain why !(x >= 5) is x < 5 and not x <= 5. [2 points]

  • Cue. x >= 5 includes x == 5; its negation must exclude 5, leaving everything strictly less than 5, so x < 5.

Exam-style practice questions

Practice questions written in the style of College Board exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AP 2022 (style)1 marksMultiple choice. Which of the following is equivalent to the expression `!(x > 0 && y < 5)` for all values of `x` and `y`? (A) `x <= 0 || y >= 5` (B) `x < 0 && y > 5` (C) `x <= 0 && y >= 5` (D) `x > 0 || y < 5` (E) `!x > 0 || !y < 5`
Show worked answer →

The answer is (A).

By De Morgan's law, !(A && B) equals !A || !B. Here A is x > 0 and B is y < 5. Negating each: !(x > 0) is x <= 0, and !(y < 5) is y >= 5. The AND becomes an OR. So the equivalent is x <= 0 || y >= 5. (C) wrongly keeps the AND; (B) negates incorrectly; (E) is not valid Java and mis-negates.

Markers reward applying De Morgan's law: negation flips && to || and negates each operand, and !(>) becomes <=, !(<) becomes >=.

AP 2020 (style)3 marksFree response (code writing). A `boolean` expression `!(a >= 10 || b == 0)` appears in a program. Rewrite it as an equivalent expression that does not use the leading `!` operator, and write a one-line comment justifying your rewrite by naming the rule used.
Show worked answer →

A 3-point question testing De Morgan's law applied to ||.

// De Morgan: !(P || Q) becomes !P && !Q
boolean result = (a < 10 && b != 0);

Point 1: !(P || Q) becomes !P && !Q, flipping || to &&. Point 2: !(a >= 10) is a < 10, and !(b == 0) is b != 0. Point 3: the comment names De Morgan's law as the justification. A common error is to flip the operands but keep ||, or to negate >= to > instead of <.

Related dot points

Sources & how we know this