Combining NOT

Using NOT together with AND and OR - precedence rules and negating compound expressions.

14 topics • ~1118 words

Precedence rules feel like trivia—until you are debugging code you wrote yourself and cannot see the bug because you are misreading the expression. Over-parenthesizing clutters code and signals uncertainty. Understanding precedence fluently means reading expressions naturally, without mentally inserting parentheses.

NOT Binds Tightest

When NOT appears in an expression with AND or OR, we need to know what NOT applies to. The rule is: NOT binds tighter than AND or OR.

This means $\neg$P $\land$ Q is read as ($\neg$P) $\land$ Q, not $\neg$(P $\land$ Q).

  • $\neg$P $\land$ Q = ($\neg$P) $\land$ Q — "NOT P, AND Q"
  • $\neg$P $\lor$ Q = ($\neg$P) $\lor$ Q — "NOT P, OR Q"

To negate an entire expression, you need parentheses: $\neg$(P $\land$ Q).

NOT on AND Operands

In expressions like $\neg$P $\land$ Q or P $\land$ $\neg$Q, the NOT applies to just one operand. To evaluate:

  1. First, apply NOT to the negated variable
  2. Then, AND the results together

NOT on OR Operands

In expressions like $\neg$P $\lor$ Q or P $\lor$ $\neg$Q, the NOT applies to just one operand. To evaluate:

  1. First, apply NOT to the negated variable
  2. Then, OR the results together

Parentheses Matter

Where's the inverter? You study two schematics. Same valves, same junction—but one inverts valve A before the connection, the other inverts the whole circuit's output. Same components, different meaning.

Parentheses change what NOT applies to:

  • $\neg$P $\land$ Q = ($\neg$P) $\land$ Q — negate P, then AND with Q
  • $\neg$(P $\land$ Q) — AND first, then negate the result

These are NOT the same! Consider P = T, Q = T:

  • $\neg$P $\land$ Q = F $\land$ T = F
  • $\neg$(P $\land$ Q) = $\neg$(T) = F

But with P = T, Q = F:

  • $\neg$P $\land$ Q = F $\land$ F = F
  • $\neg$(P $\land$ Q) = $\neg$(F) = T

Negating an AND Expression

To evaluate $\neg$(P $\land$ Q):

  1. First, evaluate the AND inside the parentheses
  2. Then, negate the result

$\neg$(P $\land$ Q) is true when P $\land$ Q is false — that is, when at least one of P or Q is false.

Negating an OR Expression

To evaluate $\neg$(P $\lor$ Q):

  1. First, evaluate the OR inside the parentheses
  2. Then, negate the result

$\neg$(P $\lor$ Q) is true when P $\lor$ Q is false — that is, when both P and Q are false.

Truth Table for $\neg$(P $\land$ Q)

The truth table for $\neg$(P $\land$ Q) is the opposite of AND:

P Q P $\land$ Q $\neg$(P $\land$ Q)
T T T F
T F F T
F T F T
F F F T

Notice: $\neg$(P $\land$ Q) is false only when both P and Q are true.

This is the opposite of AND, which is true only when both are true.

Truth Table for $\neg$(P $\lor$ Q)

The truth table for $\neg$(P $\lor$ Q) is the opposite of OR:

P Q P $\lor$ Q $\neg$(P $\lor$ Q)
T T T F
T F T F
F T T F
F F F T

Notice: $\neg$(P $\lor$ Q) is true only when both P and Q are false.

This is the opposite of OR, which is false only when both are false.

English Phrases for Negated Expressions

Some English phrases map to negated compound expressions:

  • "Not both X and Y" $\to$ $\neg$(P $\land$ Q) — at least one is false
  • "Neither X nor Y" $\to$ $\neg$(P $\lor$ Q) — both are false
  • "X but not Y" $\to$ P $\land$ $\neg$Q — first true, second false

These phrases are common in everyday reasoning and programming conditions.

Ambiguous Expressions

Invert, then junction? Or junction, then invert? You squint at the worn schematic. That is why you use notation that specifies.

Without parentheses, some expressions can be ambiguous:

  • $\neg$P $\land$ Q could mean ($\neg$P) $\land$ Q or $\neg$(P $\land$ Q)

By convention, NOT has higher precedence than AND:

  • $\neg$P $\land$ Q means ($\neg$P) $\land$ Q - negate P first, then AND with Q

But in complex expressions, always use parentheses to make intent clear.

Parsing Expressions Step by Step

To parse and evaluate a Boolean expression:

  1. Identify the structure - Find the main connective
  2. Apply precedence - NOT > AND > OR
  3. Work inside-out - Evaluate parenthesized parts first
  4. Substitute values - Replace variables with T/F
  5. Simplify step by step - One operation at a time

Common Negation Mistakes

Both valves closed blocks flow. Sure. So blocking flow means both valves closed? You pause. One closed valve also blocks. You have got the implication backwards.

Common mistakes when combining NOT with AND/OR:

Mistake 1: Thinking $\neg$(P $\land$ Q) = $\neg$P $\land$ $\neg$Q

  • Actually: $\neg$(P $\land$ Q) = $\neg$P $\lor$ $\neg$Q (De Morgan's Law)

Mistake 2: Thinking $\neg$(P $\lor$ Q) = $\neg$P $\lor$ $\neg$Q

  • Actually: $\neg$(P $\lor$ Q) = $\neg$P $\land$ $\neg$Q (De Morgan's Law)

Mistake 3: Forgetting that $\neg$P $\land$ Q $\neq$ $\neg$(P $\land$ Q)

  • Without parentheses, NOT only applies to the adjacent variable

Core Operations Synthesis

You've learned the core operations of Boolean logic:

  • NOT ($\neg$): Flips true $\leftrightarrow$ false
  • AND ($\land$): True only when both are true
  • OR ($\lor$): True when at least one is true

Precedence: NOT > AND > OR (unless parentheses override)

Core Operations Challenge

This challenge combines all core operations: NOT, AND, and OR.

Remember the evaluation order:

  1. Parentheses (innermost first)
  2. NOT operations
  3. AND operations
  4. OR operations

Ready to test your understanding?

Bitwit uses spaced repetition to help you truly master concepts like this—not just read about them. Each card generates with different values, so you can't just memorize answers.

Practice Combining NOT →