How to Make a Truth Table?
Learning to solve a truth table is one of the key steps when learning the basics of logic. Here we will teach you the general rules on how to make a truth table and the fundamental logic laws and rules for logic gates you need to solve concrete cases. By going with us through a few examples of truth tables for 3 variables, you will learn how to apply all this knowledge in practice.
🔎 Want to learn more? Read about the connections of Boolean logic and Venn diagrams!
To construct a truth table, follow these steps:
-
Identify the variables:
- Write down all the basic statements or inputs in your logical expression (like
A,B,C).
- Write down all the basic statements or inputs in your logical expression (like
-
Determine the number of rows:
- Use the formula
2ⁿ, wherenis the number of distinct variables. - Example: 2 variables means
2² = 4rows; 3 variables means2³ = 8rows.
- Use the formula
-
Create columns:
- Make a column for each variable.
- Add one extra column for the final expression you want to evaluate.
- Consider adding additional columns for intermediate steps.
-
Fill in all combinations of truth values:
- List every possible combination of True (
T) and False (F) for the variables. - Usually, alternate
TandFin a structured pattern to cover all combinations.
- List every possible combination of True (
-
Compute intermediate results and the final expression:
- For each row, evaluate its value by following the logic laws and the rules for logic gates.
- Check your calculations to avoid mistakes.
- Consider using Omni’s truth table calculator to verify your result.
As you can see, in order to make a truth table, you need to know the logic laws and understand the rules for logic gates.
Boolean logic is the foundation of digital reasoning, working with just two values: true and false. Its rules let us combine, simplify, and analyze statements efficiently, forming the core of computation. Let us have a look.
-
Operator precedence:
¬(NOT)∧(AND)∨(OR)
-
Both
∧and∨are commutative and associative. -
Complement Law:
A ∧ ¬A = FandA ∨ ¬A = T -
Identity Law:
A ∧ T = AandA ∨ F = A -
Double negation:
¬(¬A) = A -
De Morgan’s Laws:
¬(A ∧ B) = ¬A ∨ ¬Band¬(A ∨ B) = ¬A ∧ ¬B -
Distributive Laws:
A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)andA ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)
There are three basic logic gates, which form the foundation of digital logic, providing the essential operations of conjunction, disjunction, and negation:
- AND: True only if both inputs are true.
- OR: True if at least one input is true.
- NOT: Flips the input: true becomes false, false becomes true.
Next, we have the gates derived from basic gates by pairing AND or OR with a NOT to produce their inverted outputs:
- NAND: True unless both inputs are true (NOT AND).
- NOR: True when both inputs are false (NOT OR).
Finally, we have the exclusive gates, which capture relationships of difference or equality between inputs.
- XOR: True when its inputs are different: exactly one input is true and the other is false (exclusive OR).
- XNOR: True when its inputs are the same: both true or both false (exclusive NOR).
All these gates can ultimately be constructed from AND, OR, and NOT. To learn more, visit the dedicated page about logic gates.
We will now see an actual example of how to make a truth table!
Here we shall see how to make a truth table for 3 variables. We will examine the logical expression A XOR B OR C.
- List the variables. The expression has three variables: A, B, and C.
- Determine the number of rows. With three variables, you need 23 = 8 rows to cover all combinations of True (T) and False (F).
- Set up columns. Create columns for A, B, C, the intermediate result A XOR B, and the final expression A XOR B OR C.
- Fill in all combinations. List all possible combinations of T and F for A, B, and C.
- Compute intermediate results. Calculate A XOR B for each row. Recall that XOR is true if the inputs are different.
- Evaluate the final expression. Apply OR between the values of the intermediate result and C.
- Congrats! You have solved a truth table for 3 variables!
A | B | C | A XOR B | A XOR B OR C |
|---|---|---|---|---|
T | T | T | F | T |
T | T | F | F | F |
T | F | T | T | T |
T | F | F | T | T |
F | T | T | T | T |
F | T | F | T | T |
F | F | T | F | T |
F | F | F | F | F |
“You may wonder how to make a truth table for Boolean expressions with parentheses.
As always in math, the parentheses are of vital importance in getting the correct result. To see an example, let us examine:
A AND B OR C
and compare with:
A AND (B OR C)
As you remember, the operator precedence says that AND is done before OR, so the expression without any parentheses is equivalent to (A AND B) OR C. The operation that takes precedence enters the truth table as the intermediate column:
A | B | C | A AND B | (A AND B) OR C |
|---|---|---|---|---|
T | T | T | T | T |
T | T | F | T | T |
T | F | T | F | T |
T | F | F | F | F |
F | T | T | F | T |
F | T | F | F | F |
F | F | T | F | T |
F | F | F | F | F |
Next, we build the Boolean table for A AND (B OR C). Here, the intermediate step is B OR C:
A | B | C | B OR C | A AND (B OR C) |
|---|---|---|---|---|
T | T | T | T | T |
T | T | F | T | T |
T | F | T | T | T |
T | F | F | F | F |
F | T | T | T | F |
F | T | F | T | F |
F | F | T | T | F |
F | F | F | F | F |
As we can see, the two expressions do not give the same result! For example, when A = F, B = T, C = T:
- A AND B OR C = T; but
- A AND (B OR C) = F.
Here’s the full comparison:
A | B | C | (A AND B) OR C | A AND (B OR C) |
|---|---|---|---|---|
T | T | T | T | T |
T | T | F | T | T |
T | F | T | T | T |
T | F | F | F | F |
F | T | T | T | F |
F | T | F | F | F |
F | F | T | T | F |
F | F | F | F | F |
Conclusion: parentheses matter! They control the order of operations, and changing them can completely change the Boolean table.
The truth table of A implies B is:
A | B | A → B |
|---|---|---|
T | T | T |
T | F | F |
F | T | T |
F | F | T |
No, the logical expression T and F is false. This is because the logical connector and returns T if and only if both inputs are true. Since in our case the second input has the value F, the whole statement is false. The results for other input combinations can be found in the Boolean table for AND.
According to the rules of Boolean logic, expressions are evaluated in the following order:
- First, evaluate expressions inside parentheses.
- Apply NOT (¬) to invert a single value.
- Evaluate AND (∧).
- Finally, evaluate OR (∨) and XOR (⊕) (though some programming languages evaluate XOR before OR).
To construct a truth table, follow these steps:
- Identify the variables.
- Determine the number of rows. For
nvariables, you need2ⁿrows. - Prepare the columns: one for each variable, one for the final expression, and optional columns for intermediate steps.
- Fill in all combinations of
true(T) andfalse(F) for the variables. - Evaluate the expression for each row using Boolean logic rules.
This article was written by Anna Szczepanek and reviewed by Steven Wooding.