Boolean Functions and Expressions: Explained with Examples
A Boolean function is a function whose inputs and outputs can only take the two values 0 and 1, also called false and true. If a function has n inputs, there are exactly 2 to the power n possible input combinations, and the function's entire behaviour can be captured by listing its output for each combination in a truth table.
Boolean functions matter because they are the mathematical foundation of all digital electronics. Every computer chip, from a calculator to a supercomputer, is built out of circuits that implement Boolean functions, so understanding them is the first step toward understanding how computers actually work.
Key Concepts
- Boolean variable: a variable that takes only the values 0 or 1, usually named with capital letters like A, B, C.
- Boolean expression: a formula built from variables and the three basic operators NOT, AND and OR.
- Literal: a variable or its complement appearing in an expression, for example A or not-A.
- Truth table: a table listing the function output for every one of the 2 to the power n input combinations.
- Minterm: an AND product that includes every variable exactly once, such as A AND (not B) AND C.
- Maxterm: an OR sum that includes every variable exactly once, such as A OR (not B) OR C.
Formulas
- NOT: Y = not A (output is 1 exactly when A is 0).
- AND: Y = A AND B (output is 1 only when both A and B are 1).
- OR: Y = A OR B (output is 1 when at least one input is 1).
- De Morgan's laws: not (A AND B) = (not A) OR (not B), and not (A OR B) = (not A) AND (not B).
- A variable counts as 1 when it appears uncomplemented and 0 when complemented, so the minterm A AND (not B) AND C equals 1 only for the input row A=1, B=0, C=1.
Worked Example
Consider F(A, B) = (A AND not B) OR ((not A) AND B). This is the exclusive-OR function. Let us evaluate it for the input A = 1, B = 1. First not B = 0, so A AND not B = 1 AND 0 = 0. Next not A = 0, so (not A) AND B = 0 AND 1 = 0. Finally F = 0 OR 0 = 0. Repeating for all four rows: (0,0) gives 0, (0,1) gives 0 OR 1 = 1, (1,0) gives 1 OR 0 = 1, and (1,1) gives 0. The output is 1 exactly when the inputs differ.
Common Misconceptions
- "1 OR 1 = 2 in Boolean algebra." No — in Boolean OR, 1 OR 1 = 1, because OR only asks whether at least one input is true.
- "A AND B means multiply A and B." AND is just logic notation here; it is not ordinary multiplication, and Boolean algebra has its own laws (for example A OR A = A).
- "Every input combination needs a different expression." One expression covers all rows at once — the truth table is just a way of checking it.
Real-World Applications
- Designing digital circuits: chip designers specify behaviour as Boolean functions, then build gates to match.
- Search engines and databases: queries like ("AI" AND "jobs") NOT "internship" are Boolean expressions evaluated against documents.
- Programming: every if condition combining AND, OR and NOT is a Boolean expression evaluated at run time.
A Boolean function maps n binary inputs to a binary output, written as an expression and fully described by its truth table. Mastering expressions, minterms and De Morgan's laws gives you the language in which all digital logic is written.
Related blogs
- Boolean Variables and Operations: 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