LogicLab

Boolean Variables and Constants

Understand the building blocks of Boolean expressions — variables and constants — and how they model logic in digital systems.

Beginner

15 min

Before we can build complex logic expressions or design digital circuits, we need to understand the fundamental parts they’re made of. In Boolean Algebra, these building blocks are constants and variables — simple elements that represent truth values and changeable conditions. Just as regular algebra works with numbers and symbols, boolean algebra operates with true/false values and symbols that represent them. This lesson will guide you through these essential components and help you recognize how they appear in everyday logic and computation.

Introduction

In boolean logic, everything we work with boils down to two states: true or false. These two values form the basis of all boolean operations, and they are represented using constants (fixed values) and variables (changeable placeholders). Boolean constants are the unchanging “atoms” of logic — they’re always true or false — while boolean variables can shift between these two values depending on the situation.

Think of it like flipping a light switch. The states ON and OFF represent boolean constants. But whether the light is currently on or off depends on the switch — that’s your variable. When designing logic-based systems (like apps, security systems, or control panels), you’ll often describe how outputs depend on combinations of such variable conditions. Understanding how constants and variables behave is key to writing correct and efficient logic expressions.

Boolean Constants

In Boolean Algebra, constants are the simplest elements — they represent fixed, unchanging truth values. In boolean logic there are only two boolean constants:

  • 1 – Represents True
  • 0 – Represents False

These constants are universal and form the foundation of all logical expressions. Unlike variables, which can change value depending on context, constants never change. When you use 1 or 0 in a boolean expression, you’re explicitly stating that part of the logic is always true or always false.

Why Are Constants Important?

Even though they’re simple, boolean constants play a crucial role in logic simplification and design. They are often used in:

  • Default values: For example, a system might be “off” by default (0) and only turn on when certain conditions are met.

  • Identity laws: For example, A AND 1 = A and A OR 0 = A, which are used in simplifying expressions.

  • Fixed inputs in circuits: In a hardware circuit, a line tied permanently to 1 (a constant voltage) or 0 (ground) represents a Boolean constant in the physical world.

Example

Here’s a very simple boolean expression using constants:

Alarm = 0

This tells us the alarm is always off — no matter what other variables exist, this system is hardcoded to never trigger. On the other hand:

Alarm = 1

This means the alarm is always active — no logic or condition affects it.

While this seems trivial, constants are often used as base cases or defaults in larger expressions. For instance:

Light = (Switch AND 1)

This behaves the same as just Light = Switch — because AND 1 does not change the value of the variable. This is known as the identity property, and we’ll explore it further in Lesson 5.

Boolean Variables

While constants represent fixed values, boolean variables are what bring logic expressions to life. A boolean variable is a symbol (typically a letter like A, B, X, or Y) that can take on one of two values:

  • 1 (True)
  • 0 (False)

Unlike constants, variables can change depending on inputs, conditions, or system states. This makes them extremely useful for modeling real-world situations, where different conditions might be true at different times.

Real-World Analogy

Imagine a motion sensor in a room. The sensor’s state — whether motion is detected or not — can be represented by a boolean variable, say MOTION. If movement is detected, we set MOTION = 1; if not, MOTION = 0. Now, suppose we also have a variable IS_DARK, representing whether the room is dark. Using both variables, we could create a logic rule for turning on a light:

LIGHT = MOTION AND IS_DARK

This tells us: only turn the light on when there’s motion in the room and it’s dark — a clear, real-world condition expressed using boolean variables.

In Boolean Algebra, variable names are typically single capital letters, but in real systems (especially in programming), we use more descriptive names like isOnline, buttonPressed, or hasAccess.

Here’s a more abstract example:

X = (A AND B) OR C

In this expression:

  • A, B, and C are Boolean variables.
  • Their values might change depending on system input.
  • The expression tells us when X will be true, based on the values of the other variables.

Key Takeaways

  • Boolean constants are fixed values: 1 (True), 0 (False)
  • Boolean variables are symbols that can represent either 1 or 0 depending on system conditions.
  • Variables are used to describe dynamic logic, while constants represent fixed truths or defaults.
  • Boolean expressions are built by combining constants and variables using logical operators (AND, OR, NOT).
  • These basic elements are used in real-world systems like alarm logic, conditional code, and smart devices.