Skip to content

True and False

A Boolean condition is true or false. List its input combinations and check what each one produces.

  • Foundations

Here we study Boolean conditions: tests whose result is TRUE or FALSE. For an ordinary number of lives, lives > 0 is one such test.

Two possible values let us write down every input combination for a fixed number of Boolean inputs. We can then check the result for each combination.

The complete map

Take one question. Call it alive. It can be true or it can be false, and that is all.

Write both down:

alivealive
00
11
Two Boolean values. In these tables, 0 means false and 1 means true.

The 0 and 1 are our table notation. A target language may represent or accept conditions differently; check its rules before treating arbitrary numbers as these Boolean inputs.

That grid is a truth table. The left-hand column lists every case, and the columns to the right say what comes out.

Two rows is not much of a map. It matters because of what it promises: there is no case missing. Anything you can say about alive has to be true of one of those rows, and you can check both.

NOT turns it round

NOT alive is the question turned round. Where alive is true, NOT alive is false.

alivealiveNOT alive
001
110
Read across a row. When alive is 0, NOT alive is 1.

Read the table a row at a time. Pick a row, follow it across, and it tells you what happens in that case. Read it a column at a time and you see the whole behaviour of one test at once.

Both readings are useful, and the second is the one that is hard to do in your head.

Why bother writing it down

You did not need a grid to know that NOT flips an answer. For one question, the table is overkill.

The reason to learn it now is that questions do not stay single. Add a second and you have four cases. Add a third and you have eight. That is where being sure stops being possible by staring at the line, and a table stops being overkill.

The rule is worth remembering: each extra Boolean input doubles the rows. One input gives two rows, two give four, three give eight.

A full table lists combinations even when a game cannot reach some of them. Repeating a condition does not create another independent choice.

Does testing the same unchanged score twice create four possible game states?

No. If both tests are score > 0 and the score stays unchanged, they agree. Their pair of answers can be 0,0 or 1,1. A general two-input table also has rows 0,1 and 1,0, but those rows cannot arise from these repeated tests.

When it’s wrong, see why

  • The table has the wrong number of rows. Count the questions. One is two rows, two is four, three is eight. A missing row is a case you have not thought about.
  • A row repeats. With the expected number of rows, repeating one combination leaves another out. Check the inputs, not just the row count.
  • You cannot decide what a row should say. That usually means the question is two questions. Split it and give each its own column.

What you’ve learnt

  • A Boolean input has two values; a fixed number of them gives a finite table.
  • A truth table writes down every case and what comes out of each.
  • 0 is false and 1 is true.
  • NOT turns an answer round.
  • Each extra Boolean input doubles the full table; game rules may exclude some combinations.

What’s next

One question is a short table. In Unit 2 we put two of them side by side and look at the three ways of joining them.