2. Computer Organization

Boolean Logic

Boolean Logic

students, computers seem powerful, but at the lowest level they make decisions using only two states: $0$ and $1$. Boolean logic is the system that lets a computer represent truth, combine conditions, and control how circuits behave. In this lesson, you will learn the main ideas and vocabulary of Boolean logic, practice using common logic operations, and connect these ideas to computer organization and the fetch-execute cycle 💻⚡

Learning goals

By the end of this lesson, students, you should be able to:

  • explain the key ideas and terms in Boolean logic
  • use Boolean expressions to describe simple decision-making
  • apply IB Computer Science SL reasoning to logic problems
  • connect Boolean logic to hardware and computer organization
  • summarize why Boolean logic matters in a computer system

What Boolean logic means

Boolean logic is a way of working with values that have only two possible states. These states are usually written as $\text{true}$ and $\text{false}$, or as $1$ and $0$. In computers, these two values are extremely important because many hardware components can reliably represent two clear states, such as high voltage and low voltage.

A Boolean variable is a variable that can store only two values. For example, a system might use a Boolean variable called $isLoggedIn$ to store whether a user is logged in. If the user is logged in, $isLoggedIn = \text{true}$; if not, $isLoggedIn = \text{false}$.

Boolean logic is used everywhere in computing. A smartphone checks whether the screen is locked, whether Wi-Fi is available, and whether the battery is low. Each of these checks can be represented using Boolean values. This makes Boolean logic a core part of computer organization because it helps hardware and software make decisions based on yes/no conditions.

Main Boolean operations

The three basic logical operations are AND, OR, and NOT. These are used to build more complex decision rules.

NOT

The NOT operation reverses a Boolean value. If the input is $\text{true}$, the output is $\text{false}$. If the input is $\text{false}$, the output is $\text{true}$.

You can write this as $\lnot A$ or sometimes as $\overline{A}$.

Example: if $A$ means “the light is on,” then $\lnot A$ means “the light is not on.” If $A = 1$, then $\lnot A = 0$.

AND

The AND operation is true only when both inputs are true. In symbols, $A \land B$ is true only if $A = 1$ and $B = 1$.

Example: a door may open only if $cardIsValid \land pinIsCorrect$ is true. If either condition is false, the door stays locked.

Truth table for AND:

$A$ | $B$ | $A \land B$

---|---|---

$0$ | $0$ | $0$

$0$ | $1$ | $0$

$1$ | $0$ | $0$

$1$ | $1$ | $1$

OR

The OR operation is true if at least one input is true. In symbols, $A \lor B$ is true when $A = 1$, $B = 1$, or both.

Example: a message might be sent if $wifiConnected \lor mobileDataAvailable$ is true. If either connection works, the message can go through.

Truth table for OR:

$A$ | $B$ | $A \lor B$

---|---|---

$0$ | $0$ | $0$

$0$ | $1$ | $1$

$1$ | $0$ | $1$

$1$ | $1$ | $1$

Truth tables and why they matter

A truth table shows all possible input combinations for a logical expression and the output for each combination. Truth tables are a very important tool in IB Computer Science SL because they help you test and understand logic systematically.

For example, consider the expression $A \land \lnot B$.

$A$ | $B$ | $\lnot B$ | $A \land \lnot B$

---|---|---|---

$0$ | $0$ | $1$ | $0$

$0$ | $1$ | $0$ | $0$

$1$ | $0$ | $1$ | $1$

$1$ | $1$ | $0$ | $0$

This expression is true only when $A$ is true and $B$ is false. In a real-world situation, $A$ could mean “the student has completed the form,” and $B$ could mean “the form has errors.” Then $A \land \lnot B$ means the form is completed and has no errors.

Truth tables help programmers and engineers verify that a logic design behaves correctly. They also help reduce mistakes when writing conditions in code or designing hardware circuits.

Boolean logic in hardware

Boolean logic is not just a programming idea. It is built into hardware through logic gates. A logic gate is an electronic circuit that performs a Boolean operation on one or more input signals and produces an output signal.

Common logic gates include:

  • NOT gate, which performs $\lnot A$
  • AND gate, which performs $A \land B$
  • OR gate, which performs $A \lor B$

These gates are the building blocks of digital circuits. More complex operations, such as comparing numbers or making control decisions, are created by combining many gates together. For example, a CPU uses logic gates to decide whether a result is zero, whether a branch should happen, or whether a certain control signal should be turned on.

This matters in computer organization because the CPU, memory, and control unit all depend on precise binary signals. Boolean logic allows hardware to process information in a reliable way using electrical states.

Boolean logic and the fetch-execute cycle

Boolean logic is closely related to the fetch-execute cycle, which is how a CPU runs instructions.

The fetch-execute cycle usually includes these steps:

  1. fetch the next instruction from memory
  2. decode the instruction
  3. execute the instruction

During decoding and execution, Boolean logic helps the control unit make decisions. For example, the CPU may need to decide whether the current instruction is a load, add, or jump instruction. This decision can be based on condition signals that are either true or false.

Boolean logic is also used when a program contains an $if$ statement. Suppose a program checks whether $temperature > 30$. The result of that comparison is Boolean: it is either true or false. If the result is true, the program might turn on a fan. If it is false, the fan stays off. This shows how Boolean logic connects hardware and software: the CPU evaluates conditions, and the program responds with actions.

In a game, for example, a character may move if $leftArrowPressed \lor rightArrowPressed$ is true. The processor checks the input, evaluates the Boolean condition, and executes the correct instructions.

Building and reading Boolean expressions

Boolean expressions combine variables and logic operations. Examples include $A \land B$, $\lnot A$, and $(A \lor B) \land C$.

The order of operations matters. Parentheses show which part should be evaluated first. For instance, $(A \lor B) \land C$ is not the same as $A \lor (B \land C)$.

Let’s compare them with an example:

  • $A$ = “the user entered the correct password”
  • $B$ = “the user has a valid device”
  • $C$ = “the account is not locked”

Then $(A \lor B) \land C$ means: either the password is correct or the device is valid, and the account is not locked.

By contrast, $A \lor (B \land C)$ means: the password is correct, or both the device is valid and the account is not locked.

These are different conditions, so careful reading is essential. In IB-style questions, students, you may be asked to evaluate a Boolean expression for a given set of values or explain what a condition means in plain language.

Why Boolean logic is important for computer organization

Boolean logic is a foundation of digital systems because computers use binary signals internally. It supports:

  • circuit design, through logic gates
  • decision-making in programs, through conditions
  • CPU control, through instruction decoding and control signals
  • data processing, through comparisons and bitwise operations

Without Boolean logic, a computer could not reliably choose between actions or represent true/false states. Every time a computer checks whether a file exists, whether a sensor is triggered, or whether a value is greater than another value, Boolean logic is involved.

This is why Boolean logic is a key part of computer organization. It links the physical level of hardware to the logical level of computation.

Conclusion

Boolean logic gives computers a simple but powerful way to make decisions using $0$ and $1$. The main operations are NOT, AND, and OR, and these can be shown with truth tables and combined into larger expressions. Logic gates bring Boolean logic into hardware, and the CPU uses these ideas during the fetch-execute cycle to control how instructions are processed. students, understanding Boolean logic helps you understand how computers think at the hardware level and how software decisions are carried out inside a machine 🤖

Study Notes

  • Boolean logic works with two values: $\text{true}$ and $\text{false}$, or $1$ and $0$.
  • A Boolean variable stores only one of those two values.
  • The three basic operations are $\lnot$ (NOT), $\land$ (AND), and $\lor$ (OR).
  • $\lnot A$ reverses the value of $A$.
  • $A \land B$ is true only when both $A$ and $B$ are true.
  • $A \lor B$ is true when at least one input is true.
  • A truth table lists every possible input combination and the resulting output.
  • Logic gates are hardware versions of Boolean operations.
  • Boolean logic helps the CPU make decisions during the fetch-execute cycle.
  • Conditions in programs, such as $x > 5$, produce Boolean results.
  • Boolean logic is a major part of computer organization because it links hardware signals to decision-making in computing.

Practice Quiz

5 questions to test your understanding

Boolean Logic — IB Computer Science SL | A-Warded