Computer Science I / Propositional Logic
Practice question · Multiple choice

A compiler rewrites if (!(a && b)) as if (!a || !b). Which law licenses that, and why does the compiler bother?

Hints
  1. Write both truth tables and compare them.
  2. Ask what each version evaluates when a is false.
Show the answer

D. De Morgan's law, and the rewritten form can short-circuit on !a

Why

The truth tables match, so the substitution is safe, and the second form reaches a decision on !a alone where the first must evaluate the whole conjunction before negating. Equivalence is what licenses it and short-circuiting is what makes it worth doing, which is the same pairing as in logic minimisation.

Read the lesson: Propositional Logic →

Practise Propositional Logic

The app has 8 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Propositional Logic