Skip to content
IGCSE·Tuition
Computer Science · Lessons

Compare two equivalent expressions using cases

Two expressions can agree on three rows and still be different, so one lucky match proves nothing.

On this page
  1. How do you compare using cases?
  2. Worked example
  3. The mistake to watch for
  4. Check yourself
  5. Where this leads next

Two Boolean expressions are equivalent when they give the same output for every possible input. To compare them, build a column for each over all the input cases and look for a row where the columns differ.

This lesson uses the truth table method and the order of evaluation. It is part of the Boolean logic module.

How do you compare using cases?

  1. List all input cases. Two inputs give 4 cases.
  2. Evaluate expression 1 for each case.
  3. Evaluate expression 2 for each case.
  4. Compare row by row. If every row matches, they are equivalent. If any row differs, they are not.

A single mismatch is a counterexample. It settles the question at once, so you can stop.

Worked example

Are NOT (A AND B) and (NOT A) OR (NOT B) equivalent?

ABA AND BNOT (A AND B)NOT ANOT B(NOT A) OR (NOT B)
0001111
0101101
1001011
1110000

The two result columns are 1, 1, 1, 0 and 1, 1, 1, 0. All four rows match, so the expressions are equivalent.

Now compare NOT (A OR B) with (NOT A) OR (NOT B). For A = 0, B = 1: NOT (0 OR 1) = NOT 1 = 0, but (NOT 0) OR (NOT 1) = 1 OR 0 = 1.

The values differ, so the expressions are not equivalent. The counterexample is A = 0, B = 1.

The mistake to watch for

A common mistake is to test one case and conclude they are equal.

Mistaken reasoning: “For A = 0, B = 0, NOT (A OR B) = 1 and (NOT A) OR (NOT B) = 1. They match, so they are equivalent.”

One matching row proves nothing. The same two expressions differ at A = 0, B = 1. The correct approach is to check all four cases, or to stop as soon as you find a row that differs.

Check yourself

1. Are A AND (A OR B) and A equivalent?

Show answer

If A = 0: 0 AND (0 OR B) = 0, which equals A. If A = 1: 1 AND (1 OR B) = 1 AND 1 = 1, which equals A. Both cases match, so they are equivalent.

2. Are NOT (A AND B) and (NOT A) AND (NOT B) equivalent? Give a counterexample if not.

Show answer

Not equivalent. For A = 1, B = 0: NOT (1 AND 0) = NOT 0 = 1, but (NOT 1) AND (NOT 0) = 0 AND 1 = 0. The counterexample is A = 1, B = 0.

3. Are A OR ((NOT A) AND B) and A OR B equivalent?

Show answer

If A = 1: the left side is 1 OR (0 AND B) = 1, and the right side is 1 OR B = 1. If A = 0: the left side is 0 OR (1 AND B) = B, and the right side is 0 OR B = B. All cases match, so they are equivalent.

Where this leads next

Next, look at how everyday sentences can hide more than one logical reading in distinguishing logical AND from ordinary language. Then try the Boolean logic practice set. The Boolean and number-representation lab can confirm your case tables.

If you can compare expressions in class but are unsure how much working earns the mark, our teachers can go through it in online one-to-one Computer Science tuition.

Questions people ask

How do I show two expressions are equivalent?

Build a truth table for both over all input combinations and compare the output columns. If every row matches, they are equivalent. One row that differs is enough to show they are not, and that row is your counterexample.

How many cases do I need to check?

All of them: 2 to the power of the number of inputs. Two inputs need 4 cases and three inputs need 8. Checking fewer cases can only show that they differ, never that they are equal.

Can I use rules instead of a table?

Rules such as De Morgan's laws are quicker once you know them, but the case method always works and needs no memory. At IGCSE level, a clear table of cases is a reliable way to show your reasoning.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If you are not sure when a check is enough to call two expressions equal, a one-to-one teacher can go through your case tables with you and show exactly what counts as proof.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service