Truth Tables
COS1501 - Theoretical Computer Science I · Logic and Propositions
Truth Tables
Truth tables are a fundamental tool in propositional logic. They help you determine the truth value of logical expressions based on the truth values of their components. Understanding truth tables is essential for analysing logical statements and for various applications in computer science.
Basic Concepts
A proposition is a statement that can either be true (T) or false (F). Logical connectives are used to combine propositions. The main logical connectives are:
- Conjunction (AND): Denoted by ∧. The expression P ∧ Q is true only if both P and Q are true.
- Disjunction (OR): Denoted by ∨. The expression P ∨ Q is true if at least one of P or Q is true.
- Negation (NOT): Denoted by ¬. The expression ¬P is true if P is false, and vice versa.
- Implication (IF...THEN): Denoted by →. The expression P → Q is false only if P is true and Q is false.
- Biconditional (IF AND ONLY IF): Denoted by ↔. The expression P ↔ Q is true if P and Q are both true or both false.
Constructing Truth Tables
To construct a truth table, follow these steps:
- Identify the propositions involved.
- Determine the number of rows needed, which is 2^n, where n is the number of distinct propositions.
- List all possible combinations of truth values for the propositions.
- Evaluate the expression for each combination.
Example 1: Simple Truth Table
Let’s consider the propositions P and Q. We will create a truth table for the expression P ∧ Q.
Step 1: Identify propositions: P, QStep 2: Number of rows: 2^2 = 4Step 3: List combinations:Row 1: P = T, Q = TRow 2: P = T, Q = FRow 3: P = F, Q = TRow 4: P = F, Q = FStep 4: Evaluate P ∧ Q:Row 1: T ∧ T = TRow 2: T ∧ F = FRow 3: F ∧ T = FRow 4: F ∧ F = FThe completed truth table is:
| P | Q | P ∧ Q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
Example 2: Truth Table with Multiple Connectives
Now, let’s create a truth table for the expression (P ∨ Q) → ¬R. We will use three propositions: P, Q, and R.
Step 1: Identify propositions: P, Q, RStep 2: Number of rows: 2^3 = 8Step 3: List combinations:Row 1: P = T, Q = T, R = TRow 2: P = T, Q = T, R = FRow 3: P = T, Q = F, R = TRow 4: P = T, Q = F, R = FRow 5: P = F, Q = T, R = TRow 6: P = F, Q = T, R = FRow 7: P = F, Q = F, R = TRow 8: P = F, Q = F, R = FStep 4: Evaluate (P ∨ Q) → ¬R:Row 1: (T ∨ T) → ¬T = T → F = FRow 2: (T ∨ T) → ¬F = T → T = TRow 3: (T ∨ F) → ¬T = T → F = FRow 4: (T ∨ F) → ¬F = T → T = TRow 5: (F ∨ T) → ¬T = T → F = FRow 6: (F ∨ T) → ¬F = T → T = TRow 7: (F ∨ F) → ¬T = F → F = TRow 8: (F ∨ F) → ¬F = F → T = TThe completed truth table is:
| P | Q | R | (P ∨ Q) → ¬R |
|---|---|---|---|
| T | T | T | F |
| T | T | F | T |
| T | F | T | F |
| T | F | F | T |
| F | T | T | F |
| F | T | F | T |
| F | F | T | T |
| F | F | F | T |
Watch out: Ensure you correctly apply the order of operations in logical expressions. For example, negation (¬) is applied before conjunction (∧) and disjunction (∨).
Using Truth Tables for Logical Equivalence
Truth tables can also be used to determine if two logical expressions are equivalent. Two expressions are equivalent if they have the same truth values for all combinations of their variables.
Example 3: Checking Logical Equivalence
Let’s check if the expressions P → Q and ¬P ∨ Q are equivalent.
Step 1: Identify propositions: P, QStep 2: Number of rows: 2^2 = 4Step 3: List combinations:Row 1: P = T, Q = TRow 2: P = T, Q = FRow 3: P = F, Q = TRow 4: P = F, Q = FStep 4: Evaluate P → Q and ¬P ∨ Q:Row 1: T → T = T; ¬T ∨ T = F ∨ T = TRow 2: T → F = F; ¬T ∨ F = F ∨ F = FRow 3: F → T = T; ¬F ∨ T = T ∨ T = TRow 4: F → F = T; ¬F ∨ F = T ∨ F = TThe completed truth table is:
| P | Q | P → Q | ¬P ∨ Q |
|---|---|---|---|
| T | T | T | T |
| T | F | F | F |
| F | T | T | T |
| F | F | T | T |
Since both expressions have the same truth values for all combinations of P and Q, they are logically equivalent.
Remember: To check for logical equivalence, compare the columns of the truth table for the two expressions.
Summary
- Truth tables show the truth values of propositions and their combinations.
- Construct a truth table by identifying propositions, determining the number of rows, listing combinations, and evaluating expressions.
- Use truth tables to check for logical equivalence between expressions.
Check your understanding
- Construct a truth table for the expression P ∨ (Q ∧ R).
- Determine if the expressions (P ∧ Q) → R and ¬R ∨ (P ∧ Q) are logically equivalent using a truth table.
- Explain how the truth value of ¬(P ∧ Q) relates to the truth values of P and Q.
- What is the truth value of the expression P → (Q ∨ R) when P is false, Q is true, and R is false?