Boolean Variables and Operations: Explained with Examples
A Boolean variable is a variable with only two possible values: true or false, often written 1 or 0. Boolean operations — AND, OR and NOT — combine these values according to fixed rules. Boolean logic is the mathematics inside every digital circuit: your phone's processor performs billions of Boolean operations every second.
It matters because all computing is built on it. Every "if" in a program, every search filter, every logic gate in hardware is a Boolean expression. Mastering AND, OR and NOT is the first step into digital electronics and programming logic.
Key Concepts
- AND, written A · B: true only when both A and B are true.
- OR, written A + B: true when at least one of A, B is true.
- NOT, written A': flips the value — true becomes false and vice versa.
- Truth table: lists every combination of input values and the resulting output — the complete definition of any Boolean operation.
- Logic gate: the physical circuit for an operation; AND, OR and NOT gates are the building blocks of processors.
- De Morgan's laws: (A + B)' = A' · B' and (A · B)' = A' + B' — converting between AND and OR through negation.
Formulas
The basic identities of Boolean algebra (1 = true, 0 = false):
A + 0 = A; A + 1 = 1; A · 0 = 0; A · 1 = A; A + A' = 1; A · A' = 0; A + A = A; A · A = A
De Morgan's laws: (A + B)' = A' · B' and (A · B)' = A' + B'
Verify any of these with a 4-row truth table. Note A + 1 = 1: "true OR anything" is always true. Distributivity holds both ways: A · (B + C) = A·B + A·C and A + B·C = (A + B) · (A + C) — the second has no counterpart in ordinary arithmetic. Here + means OR, never arithmetic addition, and variables take only the values 0 and 1.
Worked Example
Simplify F = A·B + A'·B + A·B'. Step 1: factor B from the first two terms: A·B + A'·B = B·(A + A') = B·1 = B. Step 2: F = B + A·B'. Step 3: B + A·B' = (B + A)·(B + B') = (B + A)·1 = A + B. Verify by truth table: (0,0) → original 0, simplified 0; (0,1) → 1 and 1; (1,0) → 1 and 1; (1,1) → 1 and 1 — all rows match. Evaluate at A = 1, B = 0: F = 1 + 0 = 1 (true). Check De Morgan: (A + B)' = (1 + 0)' = 0, and A'·B' = 0·1 = 0 — equal, as the law promises.
Common Misconceptions
- Boolean + is OR, not addition. 1 + 1 = 1 in Boolean algebra, because "true OR true" is true. Carrying arithmetic habits into Boolean algebra causes errors.
- NOT binds tightest, then AND, then OR. A' + B·C means (NOT A) OR (B AND C), not NOT (A + B·C). Parentheses remove all doubt.
- De Morgan's laws flip the operator. The negation of an OR is an AND of negations, not an OR of negations — forgetting to flip AND to OR (or vice versa) is the most common simplification mistake.
Real-World Applications
- Digital circuits: processors, memory and every chip are built from AND, OR and NOT gates.
- Programming: every if-condition, while-loop test and search filter is a Boolean expression.
- Database queries: SQL WHERE clauses combine conditions with AND, OR and NOT.
- Control systems: elevator and safety-interlock logic is designed as Boolean expressions, then simplified to use fewer gates.
A Boolean variable is just true or false, and AND, OR and NOT combine values by truth-table rules. The identities — especially De Morgan's laws — simplify any expression into smaller, cheaper circuits.
Related blogs
- Boolean Functions and Expressions: Explained with Examples
- Laws of Boolean Algebra: Theorems with Simple Examples
- Canonical Forms Sop Pos: Concepts, Formulas and Examples
- Karnaugh Maps: Simplify Boolean Expressions with K-Maps
- Logic Gates and Circuits: From AND Gates to Adders
- Finite Automata Explained: DFA, NFA and State Diagrams