Boolean Logic (OCR A-Level Computer Science): Revision Notes
Boolean Logic
Overview
Boolean Logic is the foundation of digital circuits and computational logic. It involves expressions that evaluate to either True (1) or False (0), and it uses logical operators such as AND, OR, NOT, and XOR to form more complex conditions.
This note will guide you through defining problems using Boolean logic, constructing truth tables, and working with logic gates.
Boolean Operators and Truth Tables
AND (Conjunction, ∧):
Returns True if both inputs are True.
Truth Table:
| A | B | A ∧ B |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
OR (Disjunction, ∨):
Returns True if at least one input is True.
Truth Table:
| A | B | A ∨ B |
|---|---|---|
| T | T | T |
| T | F | T |
| F | T | T |
| F | F | F |
NOT (Negation, ¬):
Returns the inverse of the input.
Truth Table:
| A | ¬A |
|---|---|
| T | F |
| F | T |
XOR (Exclusive OR, ⊕):
Returns True if exactly one input is True.
Truth Table:
| A | B | A ⊕ B |
|---|---|---|
| T | T | F |
| T | F | T |
| F | T | T |
| F | F | F |
Constructing Logic Gate Diagrams from Boolean Expressions
Boolean expressions can be represented as logic gate diagrams. Here's a summary of the key gates:
- AND Gate: Outputs
Trueonly if both inputs areTrue. - OR Gate: Outputs
Trueif at least one input isTrue. - NOT Gate: Inverts the input.
- XOR Gate: Outputs
Trueif exactly one input isTrue.
Example Expression:
Diagram:
- First, use a NOT Gate for .
- Then, use an OR Gate to combine and
- Finally, use an AND Gate to combine with the result of ()
Constructing Boolean Expressions from Logic Gate Diagrams
- Identify the gates and their connections.
- Start from the inputs and move towards the output.
- Combine sub-expressions for each gate.
Example Given a diagram with:
- An AND Gate combining and
- The output of this AND Gate feeds into an OR Gate with input The corresponding Boolean expression is:
Constructing Truth Tables
A truth table lists all possible combinations of input values and their corresponding output.
Example For the expression
| A | B | |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
Examples of Problem Definition
- Problem: Is the light on?
- Logic: Light turns on when switch1 AND switch2 are ON.
- Boolean Expression:
- Problem: Car alarm activation.
- Logic: Alarm activates if door open OR ignition ON while key not present.
- Boolean Expression:
Note Summary
Common Mistakes
- Incorrect Truth Table Construction:
- Ensure all combinations of inputs are included.
- Use the correct operator logic for each row.
- Misinterpreting Logic Diagrams:
- Follow the signal flow from the inputs to the output systematically.
- Incorrect Use of XOR:
- Confusing XOR with OR. XOR is true only when exactly one input is true.
- Order of Operations:
- Apply NOT before AND or OR in compound expressions.
Key Takeaways
- Boolean logic forms the basis of computational logic and circuit design.
- Understand the behaviour of AND, OR, NOT, and XOR operators through truth tables.
- Practice converting between Boolean expressions, truth tables, and logic gate diagrams.
- Ensure accuracy by systematically constructing and validating truth tables and diagrams.