Boolean logic

Boolean logic or Boolean algebra is a branch of algebra where every variable in a formula is either True or False.

Boolean logic was introduced by a 19th-century mathematician and philosopher by the name of George Boole and it is one of the pillars of modern computing, as it went on to be the basis of all digital electronics. You will find a Boolean type in almost all current programming languages.

  • Boolean True is equivalent to 1 or, in Minecraft, to ON.
  • Boolean False is equivalent to 0 or, in Minecraft, to OFF.

In normal algebra, you have a series of operators, typically to do with arithmetic or comparison: +, -, *, /, >, <, etc. Similarly, there are operators in Boolean logic. They are sometimes called gates or logic gates and they take  certain number of inputs and produce one output.

  • NOT is used to invert a value. NOT True is False, and NOT False is True.
  • OR is True if any of the inputs are true.
  • AND is True if all of the inputs are true.

You can combine these in many different ways to make other gates, but you can think of NOT, OR and AND as the basic building blocks for any logic circuit.

Each of the logic gates possible has its own truth table, which is a table listing the corresponding outputs for every set of inputs possible. You’ll see some later.

Real computers are built by combining millions of these gates.

In the next chapter, we will be building all three of these in Minecraft.