Boolean Expressions
Evaluating with 1 and 0
Evaluate $A \land \neg B$ for $A = 1$ and $B = 0$.
Substitute the values: Replace $A$ with $1$ and $B$ with $0$ = $1 \land \neg 0$
Do NOT first: $\neg 0 = 1$ = $1 \land 1$
Do AND: Both values are $1$, so AND gives $1$ = $1$
Answer: $A \land \neg B = 1$ (true) for $A = 1$, $B = 0$.
AND Before OR
Evaluate $A \lor B \land C$ for $A = 1$, $B = 0$, $C = 0$.
Substitute the values: Replace each letter with its value = $1 \lor 0 \land 0$
Do AND before OR: $0 \land 0 = 0$ = $1 \lor 0$
Do OR: At least one value is $1$ = $1$
Compare with left to right: Working left to right would give $(1 \lor 0) \land 0 = 1 \land 0 = 0$ = A different, wrong result
Answer: $A \lor B \land C = 1$. Working left to right gives $0$, which is wrong because AND comes before OR.
Parentheses Change the Result
Evaluate $\neg(A \land B)$ and $\neg A \land B$ for $A = 0$ and $B = 0$.
First expression: parentheses first: $A \land B = 0 \land 0 = 0$ = $\neg(0)$
Then NOT: $\neg 0 = 1$ = $\neg(A \land B) = 1$
Second expression: NOT applies only to $A$: $\neg A = \neg 0 = 1$ = $1 \land B$
Then AND: $1 \land 0 = 0$ = $\neg A \land B = 0$
Answer: $\neg(A \land B) = 1$ but $\neg A \land B = 0$. The parentheses decide what NOT is applied to.
A Full Truth Table and Equivalence
Build the truth table of $A \lor \neg A \land B$ and compare it with $A \lor B$.
Count the rows: 2 variables, so $2^2 = 4$ rows = $AB$: 00, 01, 10, 11
Helper column $\neg A$: Flip $A$: 0, 0, 1, 1 = $\neg A$: 1, 1, 0, 0
Helper column $\neg A \land B$ (AND before OR): $\neg A$: 1, 1, 0, 0 AND $B$: 0, 1, 0, 1 = 0, 1, 0, 0
Final column $A \lor (\neg A \land B)$: $A$: 0, 0, 1, 1 OR 0, 1, 0, 0 = 0, 1, 1, 1
Column of $A \lor B$ and comparison: $A \lor B$: 0, 1, 1, 1 = Same in all 4 rows
Answer: Both final columns are 0, 1, 1, 1, so $A \lor \neg A \land B$ and $A \lor B$ are equivalent: the shorter expression does the same job.
Three Variables: Where the Parentheses Go
Build the truth tables of $A \land (B \lor C)$ and $A \land B \lor C$. Are they equivalent?
Count the rows: 3 variables, so $2^3 = 8$ rows: 000, 001, 010, 011, 100, 101, 110, 111 = 8 rows
Helper column $B \lor C$: $B \lor C$ is $0$ only when $B = C = 0$ = 0, 1, 1, 1, 0, 1, 1, 1
Final column $A \land (B \lor C)$: $A$ is $1$ only in the last 4 rows = 0, 0, 0, 0, 0, 1, 1, 1
Final column $A \land B \lor C = (A \land B) \lor C$: $A \land B$: 0, 0, 0, 0, 0, 0, 1, 1. OR with $C$: 0, 1, 0, 1, 0, 1, 0, 1 = 0, 1, 0, 1, 0, 1, 1, 1
Compare the columns: They differ in row 2 (001) and row 4 (011) = Not equivalent
Answer: The expressions are not equivalent: for $A = 0$, $B = 0$, $C = 1$ the first gives $0$ and the second gives $1$. One row that differs is enough.
Mistake: Working left to right: $1 \lor 0 \land 0 = (1 \lor 0) \land 0 = 0$
Why: AND comes before OR, just as multiplication comes before addition. Without parentheses, the AND part is done first.
Correct: $1 \lor 0 \land 0 = 1 \lor (0 \land 0) = 1 \lor 0 = 1$
Mistake: Applying NOT to everything after it: reading $\neg A \land B$ as $\neg(A \land B)$
Why: Without parentheses, NOT applies only to the variable directly after it.
Correct: $\neg A \land B = (\neg A) \land B$. To negate the whole AND, write $\neg(A \land B)$.
Mistake: Adding like numbers: $1 \lor 1 = 2$
Why: A Boolean expression can only be $1$ or $0$. OR asks whether at least one value is $1$, it does not count them.
Correct: $1 \lor 1 = 1$, $1 \land 1 = 1$ and $\neg 1 = 0$. The answer is always $1$ or $0$.
Mistake: Calling two expressions equivalent after testing only one or two inputs
Why: $A \land (B \lor C)$ and $A \land B \lor C$ give the same value in 6 of the 8 rows, yet they are different.
Correct: Build the full table with $2^n$ rows and compare every row. One row that differs means not equivalent.
Rules in a Program
Programmers write rules as Boolean expressions and test every combination of inputs before the program goes live.
A theme park ride lets you in if $T \land (H \lor P)$: $T$ = you have a ticket, $H$ = you are tall enough, $P$ = a parent rides with you.
Spam Filters
An email program decides with a Boolean expression whether a message goes to the spam folder.
A filter marks an email as spam if $L \lor S \land \neg K$: $L$ = sender is on a block list, $S$ = suspicious words, $K$ = sender is in your contacts.
Smart Home Rules
Two different expressions can control a device in exactly the same way. A truth table shows when a long rule can be replaced by a short one.
A garden light uses the rule $M \lor M \land N$: $M$ = motion detected, $N$ = it is night.
A Boolean expression combines variables, the values 1 (true) and 0 (false) and the operators $\land$, $\lor$, $\neg$
The value of a Boolean expression is always 1 or 0, never 2 or more
Order of operations: parentheses first, then NOT, then AND, then OR
NOT applies only to what comes directly after it: $\neg A \land B$ is not $\neg(A \land B)$
An expression with $n$ variables has a truth table with $2^n$ rows, starting with the row where all variables are 0
Two expressions are equivalent when their final columns are the same in every row
Q: Why does AND come before OR?
A: It is a convention, like multiplication before addition. With 0 and 1, AND behaves like multiplication ($1 \times 0 = 0$), and OR is often compared to addition, so the same order feels natural.
Q: Can I just use parentheses everywhere?
A: Yes. Parentheses that only show the order of operations never change the value, and they make the expression easier to read. $A \lor (B \land C)$ is the same as $A \lor B \land C$, but the first version shows the order at a glance.
Q: Are 1 and 0 the same as true and false?
A: Yes. 1 stands for true and 0 for false. Computers use 1 and 0 because they store everything as bits. The interactive tables in this lesson use 1 and 0 too.
Q: Is there a faster way than a truth table to show that two expressions are equivalent?
A: Yes. Boolean algebra has laws (such as De Morgan's laws) that turn one expression into another step by step. You will learn them in the Boolean Algebra lesson. A truth table is slower but always works.
Boolean Expressions
1 / 14
Boolean Expressions
Learn to write and evaluate Boolean expressions with 1 and 0, use the order of operations NOT, AND, OR, and build their full truth tables.