Skip to content
SPM Tuition
Free tool · Computer Science

Boolean expression and truth-table explorer

You can read a logic expression but lose marks when a truth table row comes out wrong.

This tool turns a Boolean expression into a truth table and shows how it was read. It helps students who want to check a table they built by hand, or decide whether two expressions mean the same thing.

Everything you enter stays on this device.

How do I use it?

  1. Type an expression in the first box, for example A AND NOT B.
  2. Optionally type a second expression to compare with the first.
  3. Press “Show truth table” and read the bracketed reading, the table and the list of rows where the output is 1.
  4. Use “Print this explanation” to keep a copy for revision.

How does it work?

The tool splits your text into names, 0, 1, AND, OR, NOT and brackets. NOT binds tightest, then AND, then OR, and operators of the same kind are read from left to right. The result is shown fully bracketed, so A OR B AND C appears as (A OR (B AND C)).

With n different names there are 2^n rows, written in counting order from all 0 to all 1. Each row is worked out from the parsed expression, and the tool reads your text as a formula only, so nothing you type is run as code.

When you add a second expression, both are compared over every name used in either one. The first row where the outputs differ is reported as a counterexample.

A short worked example

Take A AND NOT B. The four rows (A, B) = (0,0), (0,1), (1,0), (1,1) give 0, 0, 1, 0. Only A=1 with B=0 makes the output 1, because NOT B must be 1.

Now compare NOT (A OR B) with NOT A AND NOT B. Both give 1, 0, 0, 0 down the four rows, so they are equivalent. That is one of De Morgan’s laws.

A common slip is to read A OR B AND C as (A OR B) AND C. The two differ at A=1, B=0, C=0, where the first gives 1 and the second gives 0, and the tool shows exactly that counterexample.

What are its limits?

The tool accepts up to four names and expressions of up to 120 characters. It uses AND, OR and NOT only, so XOR, NAND and NOR need to be written out with these. Your textbook may draw or write the same operators differently, and the tool is a learning aid that gives no marks.

Where does it connect to the lessons?

Start with reading Boolean expressions and truth tables and the wider Boolean logic and representation topic. For longer expressions, practise building a truth table from a nested Boolean expression.

If tables keep going wrong, SPM Computer Science tuition gives you a teacher to work through them with. The one-hour trial class (from RM50) is the first step.

Common questions

Which order does the tool use for AND, OR and NOT?

NOT is applied first, then AND, then OR. So A OR B AND C is read as A OR (B AND C). The tool shows the fully bracketed version so you can see the reading, and you can add your own brackets to change it.

How many inputs can I use?

Up to four different names in total, which gives at most 16 rows. Five names would need 32 rows, so the tool asks you to reduce them instead of showing a table that is hard to read.

What does it mean when two expressions are equivalent?

Equivalent expressions give the same output in every row of the truth table. If one row differs, the tool shows that row as a counterexample, which is enough to prove they are different.

Can I use symbols instead of words?

Yes. The tool accepts & for AND, | or + for OR, and ! or ~ for NOT. Match the notation to the symbols in your own notes, since textbooks vary.

A teacher can take the expressions you keep getting wrong in a one-to-one lesson, build each table with you row by row, and practise until you can do it without the tool.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.