Boolean operators: Basic logical operations AND, OR, NOT, NAND, NOR, XOR
1. The big three: AND, OR, and NOT
These three operators are the simplest and most essential. Imagine you have two light switches controlling a bulb. The bulb’s state (ON or OFF) depends on how you combine the switches.
AND (conjunction): The output is true only if all inputs are true. In math: $A \cdot B = Q$ or $A \land B = Q$.
OR (disjunction): The output is true if at least one input is true. In math: $A + B = Q$ or $A \lor B = Q$.
NOT (negation): The output is the opposite of the input. In math: $\overline{A} = Q$ or $A' = Q$.
| A | B | AND (A·B) | OR (A+B) | NOT A |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 |
2. Universal gates: NAND and NOR
NAND (NOT AND) and NOR (NOT OR) are called universal gates because you can build any other gate using only NAND or only NOR gates. They are like the "super tools" of digital logic.
NAND: The opposite of AND. Output is false only when all inputs are true. Formula: $\overline{A \cdot B} = Q$.
NOR: The opposite of OR. Output is true only when all inputs are false. Formula: $\overline{A + B} = Q$.
| A | B | NAND (A↑B) | NOR (A↓B) |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
3. The inequality detector: XOR
XOR (exclusive OR) outputs true only when the inputs are different. It’s like asking: "Are they not equal?" In math: $A \oplus B = Q$.
| A | B | XOR (A⊕B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
4. How we use Boolean operators every day
🔍 Search engines: When you type "cats AND dogs" in a search bar, you get pages that mention both words. Using "cats OR dogs" gives pages that mention either. Adding a minus sign acts like NOT (e.g., "cats -dogs").
💡 Electronics: Inside your calculator, XOR gates check if two binary digits are different—this is the first step in addition. NAND gates are everywhere because they are cheap to manufacture; an entire computer can be built using only NAND chips.
🎮 Game development: In coding, you might write: if (health > 0 AND ammo > 0): to allow the player to shoot.
📊 Spreadsheets: Functions like =AND(condition1, condition2) return TRUE only if all conditions are true.
5. Frequently asked questions about Boolean logic
You can create any other gate—AND, OR, NOT, XOR—by combining just NAND gates (or just NOR gates). For example, connecting both inputs of a NAND turns it into a NOT gate. This universality simplifies chip manufacturing.
OR gives true if any input is true, including both. XOR gives true only when the inputs are different—so for (1,1), OR is 1 but XOR is 0. Think of XOR as "one or the other but not both."
Use mnemonics: AND is like multiplication (0·0=0, 0·1=0, 1·1=1). OR is like addition but with 1+1=1 (not 2). NOT is just inversion. For NAND, think of AND and then flip the result.
📚 Footnote: Key terms explained
Boolean algebra [1]: A branch of algebra dealing with true/false values, invented by George Boole.
Truth table [2]: A table showing all possible input combinations and their corresponding outputs.
Binary [3]: A number system using only two digits, 0 and 1, which maps directly to Boolean logic.
Gate [4]: An electronic circuit that performs a Boolean operation.
Universal gate [5]: A gate (NAND or NOR) that can be used to create any other Boolean function.
