Boolean operators
Boolean operators are used to connect and compare the relationship between argumentThe values of pieces of data or parameters provided as input into a function.. The result will be either TRUE or FALSE.
| Boolean operation | Operator | Example |
| Both statements must be true for the argument as a whole to be true. | | Returns if is any number between 5 and 20. |
| Only one of the statements needs be true for the argument as a whole to be true. | | Returns if is either 2 or 5. |
| The opposite of the argument is true. | | Returns if is not 10. |
| The argument is false if both statements are true. The argument is false if both statements are false. Otherwise the argument is true. | | Returns if one of or is greater than 10 and the other is not. |
| Boolean operation | Both statements must be true for the argument as a whole to be true. |
|---|---|
| Operator | |
| Example | Returns if is any number between 5 and 20. |
| Boolean operation | Only one of the statements needs be true for the argument as a whole to be true. |
|---|---|
| Operator | |
| Example | Returns if is either 2 or 5. |
| Boolean operation | The opposite of the argument is true. |
|---|---|
| Operator | |
| Example | Returns if is not 10. |
| Boolean operation | The argument is false if both statements are true. The argument is false if both statements are false. Otherwise the argument is true. |
|---|---|
| Operator | |
| Example | Returns if one of or is greater than 10 and the other is not. |
These can also be combined, for example:
If (x AND y) OR (NOT C)Truth tables
truth tableA table to list the output for all possible input combinations into a logic gate. are a way of showing all the possible outputs for inputs in a logical expression. logic gateCircuit components which take several inputs, compare the inputs with each other, and provide a single output based on logical functions such as AND, OR, NOT and XOR., used in electronics and therefore computer circuits, are based on truth tables. More complex expressions can combine several inputs and outputs. In the following tables, 1 means TRUE and 0 means FALSE.
AND truth table
| A | B | Output |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| A | 0 |
|---|---|
| B | 0 |
| Output | 0 |
| A | 0 |
|---|---|
| B | 1 |
| Output | 0 |
| A | 1 |
|---|---|
| B | 0 |
| Output | 0 |
| A | 1 |
|---|---|
| B | 1 |
| Output | 1 |
In an AND truth table, the output is only TRUE if both inputs are also TRUE.
OR truth table
| A | B | Output |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
| A | 0 |
|---|---|
| B | 0 |
| Output | 0 |
| A | 0 |
|---|---|
| B | 1 |
| Output | 1 |
| A | 1 |
|---|---|
| B | 0 |
| Output | 1 |
| A | 1 |
|---|---|
| B | 1 |
| Output | 1 |
In an OR truth table, the output is TRUE if any of the inputs are TRUE.
NOT truth table
| A | Output |
| 0 | 1 |
| 1 | 0 |
| A | 0 |
|---|---|
| Output | 1 |
| A | 1 |
|---|---|
| Output | 0 |
A NOT truth table reverses the input value.
XOR truth table
| A | B | Output |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| A | 0 |
|---|---|
| B | 0 |
| Output | 0 |
| A | 0 |
|---|---|
| B | 1 |
| Output | 1 |
| A | 1 |
|---|---|
| B | 0 |
| Output | 1 |
| A | 1 |
|---|---|
| B | 1 |
| Output | 0 |
In an XOR truth table, the output is TRUE if only one of the input values is TRUE.
Boolean notation
Logical expressions can also be expressed using Boolean algebra notation. Instead of writing the words AND, OR, NOT or XOR it is often written using the following shorthand notation.
| Boolean expression | Shorthand notation |
| A AND B | A . B |
| A OR B | A + B |
| NOT A | A’ (can be also shown as Ā) |
| A XOR B | A ⊕ B |
| Boolean expression | A AND B |
|---|---|
| Shorthand notation | A . B |
| Boolean expression | A OR B |
|---|---|
| Shorthand notation | A + B |
| Boolean expression | NOT A |
|---|---|
| Shorthand notation | A’ (can be also shown as Ā) |
| Boolean expression | A XOR B |
|---|---|
| Shorthand notation | A ⊕ B |
Boolean identities and rules
| Rule | AND form | OR form |
| Commutative law | A . B = B . A | A + B = B + A |
| Associative law | (A . B) . C = A . (B . C) | (A + B) + C = A + (B + C) |
| Distributive law | (A . B) + C = (A + C) . (B + C) | (A + B) . C = (A . C) + (B . C) |
| Identity law | A . 1 = A | A + 0 = A |
| Zero and one law | A . 0 = 0 | A + 1 = 1 |
| Inverse law | A . A’ = 0 | A + A’ = 1 |
| Idempotent law | A . A = A | A + A = A |
| Absorption law | A . (A + B) = A | A + A . B = A A + A’ B = A + B |
| Double complement law | Ā = A |
| Rule | Commutative law |
|---|---|
| AND form | A . B = B . A |
| OR form | A + B = B + A |
| Rule | Associative law |
|---|---|
| AND form | (A . B) . C = A . (B . C) |
| OR form | (A + B) + C = A + (B + C) |
| Rule | Distributive law |
|---|---|
| AND form | (A . B) + C = (A + C) . (B + C) |
| OR form | (A + B) . C = (A . C) + (B . C) |
| Rule | Identity law |
|---|---|
| AND form | A . 1 = A |
| OR form | A + 0 = A |
| Rule | Zero and one law |
|---|---|
| AND form | A . 0 = 0 |
| OR form | A + 1 = 1 |
| Rule | Inverse law |
|---|---|
| AND form | A . A’ = 0 |
| OR form | A + A’ = 1 |
| Rule | Idempotent law |
|---|---|
| AND form | A . A = A |
| OR form | A + A = A |
| Rule | Absorption law |
|---|---|
| AND form | A . (A + B) = A |
| OR form | A + A . B = A A + A’ B = A + B |
| Rule | Double complement law |
|---|---|
| AND form | Ā = A |
Examples:
A AND A = A
How?
If A is 0, then the expression is 0 AND 0 = 0, which is equal to A.
If A is 1, then the expression is 1 AND 1 = 1, which is equal to A.
A OR A = A
How?
If A is 0, then the expression is 0 OR 0 = 0, which is equal to A.
If A is 1, then the expression is 1 OR 1 = 1, which is equal to A.
A AND NOT A = 0
How?
If A is 1, then NOT A = 0.
Then the expression becomes 1 AND 0 = 0.
If A is 0, then NOT A = 1.
Then the expression becomes 0 AND 1 = 0.
Simplifying Boolean expressions
You may be asked to simplify a Boolean expression, for example:
X = A AND B OR A AND NOT B
X = A AND (B OR NOT B)
X = A AND 1
X = A
More guides on this topic
- The CPU - Eduqas
- Primary storage - Eduqas
- Secondary storage and embedded systems - Eduqas
- Networks - Eduqas
- Internet and cybersecurity - Eduqas
- Storage and data organisation - Eduqas
- Operating systems - Eduqas
- Principles of programming - Eduqas
- Algorithms - Eduqas
- Sorting, searching and validation - Eduqas
- Software development - Eduqas
- Impacts of digital technology on wider society - Eduqas