📚 Logic Gates and Truth Tables | 逻辑门与真值表
In IB Mathematics and Computer Science, logic gates form the basis of Boolean algebra, which is used to describe and simplify digital circuits. Truth tables are a systematic way to represent the output of a logic gate (or a compound logical expression) for every possible combination of inputs.
在 IB 数学与计算机科学中,逻辑门构成布尔代数的基础,用于描述和简化数字电路。真值表则是一种系统化的工具,用来展示逻辑门(或复合逻辑表达式)在所有可能输入组合下的输出结果。
1. What Are Logic Gates and Truth Tables? | 什么是逻辑门与真值表
A logic gate is an abstract electronic device that performs a Boolean function on one or more binary inputs and produces a single binary output. The inputs and outputs are usually represented by 0 (false) and 1 (true).
逻辑门是一种抽象的电子器件,它对一个或多个二进制输入执行布尔函数,并产生一个二进制输出。输入和输出通常用 0(假)和 1(真)表示。
A truth table lists every possible combination of input values in the left columns, and the corresponding output of the gate or expression in the rightmost column. If there are n inputs, the table has 2ⁿ rows.
真值表在左侧列出所有可能的输入组合,在最右侧给出对应门电路或表达式的输出。若有 n 个输入,则真值表包含 2ⁿ 行。
2. Basic Logical Values and Connectives | 基本逻辑值与逻辑连接词
There are three fundamental logical operations that correspond to the core logic gates: NOT (¬), AND (∧) and OR (∨). A fourth common operation is exclusive OR (XOR, ⊕), plus their negated forms NAND, NOR and XNOR.
有三种基本逻辑运算对应核心逻辑门:非(¬)、与(∧)和或(∨)。第四种常见运算是异或(XOR,⊕),以及它们的否定形式与非(NAND)、或非(NOR)和同或(XNOR)。
In IB problems, you may be asked to write the truth table for a given gate or to determine the Boolean expression from a table. Remember that the symbols 0 and 1 are interchangeable with F and T.
在 IB 题目中,你可能会被要求写出给定门电路的真值表,或根据真值表确定布尔表达式。请记住,0 和 1 可分别与 F 和 T 互换。
3. NOT Gate (¬) | 非门(¬)
The NOT gate takes a single input and reverses it. If A = 0 then output is 1; if A = 1 then output is 0.
非门接收单个输入并将其取反。如果 A = 0,输出为 1;如果 A = 1,输出为 0。
| A | ¬A |
| 0 | 1 |
| 1 | 0 |
As a Boolean expression, the output is written as ¬A or A’.
对应的布尔表达式写作 ¬A 或 A’。
4. AND Gate (∧) | 与门(∧)
The AND gate has two or more inputs. Its output is 1 only when all inputs are 1; otherwise the output is 0.
与门有两个或多个输入。只有当所有输入均为 1 时输出才为 1;否则输出为 0。
| A | B | A ∧ B |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
In Boolean algebra, A ∧ B is often written as AB, meaning multiplication in a binary setting.
在布尔代数中,A ∧ B 常简写为 AB,可类比于二进制乘法。
5. OR Gate (∨) | 或门(∨)
The OR gate outputs 1 when at least one of its inputs is 1. It outputs 0 only when all inputs are 0.
或门在至少一个输入为 1 时输出 1。只有当所有输入均为 0 时才输出 0。
| A | B | A ∨ B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
In Boolean notation, A ∨ B is sometimes written as A + B, so it resembles addition but with the special rule that 1 + 1 = 1.
布尔表达式中,A ∨ B 有时写作 A + B,虽然类似加法,但必须注意特殊规则:1 + 1 = 1。
6. NAND Gate (¬(A ∧ B)) | 与非门(¬(A ∧ B))
The NAND gate is the complement of AND. Its output is 0 only when both inputs are 1, and 1 in all other cases.
与非门是与门的取反。只有当两个输入均为 1 时输出才为 0,其余情况输出均为 1。
| A | B | ¬(A ∧ B) |
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NAND is a universal gate, meaning any other logic gate can be constructed using only NAND gates. This property is frequently used in circuit design and appears in IB extension questions.
与非门是通用门,即仅使用与非门就能构造出任何其他逻辑门。这一性质常用于电路设计,也可能出现在 IB 拓展题中。
7. NOR Gate (¬(A ∨ B)) | 或非门(¬(A ∨ B))
The NOR gate is the complement of OR. It outputs 1 only when both inputs are 0.
或非门是或门的取反。仅当两个输入均为 0 时输出才为 1。
| A | B | ¬(A ∨ B) |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Like NAND, NOR is also a universal gate. In Boolean algebra, ¬(A ∨ B) is equivalent to (¬A) ∧ (¬B), which is one half of De Morgan’s laws.
与非门一样,或非门也是通用门。在布尔代数中,¬(A ∨ B) 等价于 (¬A) ∧ (¬B),这正是德摩根定律的一半。
8. XOR Gate (A ⊕ B) | 异或门(A ⊕ B)
The XOR (exclusive OR) gate outputs 1 when the two inputs are different, and 0 when they are the same. The mathematical symbol is ⊕.
异或门在两个输入不同时输出 1,相同时输出 0。数学符号为 ⊕。
| A | B | A ⊕ B |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XOR can also be expressed in terms of AND, OR and NOT: A ⊕ B = (A ∧ ¬B) ∨ (¬A ∧ B).
异或也可以用与、或、非表达:A ⊕ B = (A ∧ ¬B) ∨ (¬A ∧ B)。
9. XNOR Gate (¬(A ⊕ B)) | 同或门(¬(A ⊕ B))
The XNOR gate is the complement of XOR. It outputs 1 when the two inputs are equal, and 0 when they are different.
同或门是异或门的取反。当两个输入相同时输出 1,不同时输出 0。
| A | B | ¬(A ⊕ B) |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
XNOR is sometimes written as A ↔ B, meaning “A if and only if B”. In binary arithmetic it also corresponds to the “equality” operation.
同或有时写作 A ↔ B,表示“A 当且仅当 B”。在二进制算术中它也对应“相等”运算。
10. Constructing a Truth Table for a Compound Expression | 构建复合表达式的真值表
When building a truth table for an expression with multiple gates, follow a step-by-step method:
当为包含多个门电路的复合表达式构建真值表时,应按以下分步方法进行:
-
First count the number of distinct input variables, n. The table will have 2ⁿ rows.
首先计算不同输入变量的数量 n,真值表将包含 2ⁿ 行。
-
List all input combinations in a consistent binary order, from 00…0 to 11…1.
按一致的二进制顺序列出所有输入组合,从 00…0 到 11…1。
-
Add a separate column for each intermediate operation, then the final output.
为每个中间运算添加单独一列,最后再写最终输出列。
For example, consider the expression F = (A ∧ B) ∨ (¬A ∧ C). With three inputs, the truth table has 8 rows:
例如,考虑表达式 F = (A ∧ B) ∨ (¬A ∧ C)。由于有三个输入,真值表共有 8 行:
| A | B | C | ¬A | A ∧ B | ¬A ∧ C | F |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | 1 |
| 1 | 1 | 1 | 0 | 1 | 0 | 1 |
Always check that the number of rows equals 2ⁿ. This avoids missing combinations in tests.
始终检查行数是否等于 2ⁿ,这样可避免在考试中遗漏输入组合。
11. Key Identities and De Morgan’s Laws | 重要恒等式与德摩根定律
Understanding Boolean identities helps simplify expressions before drawing truth tables or circuit diagrams.
理解布尔恒等式有助于在绘制真值表或电路图之前简化表达式。
De Morgan’s laws are especially important:
德摩根定律尤为重要:
¬(A ∧ B) ≡ ¬A ∨ ¬B
¬(A ∨ B) ≡ ¬A ∧ ¬B
These laws can be verified by constructing truth tables for both sides. For example, the column for ¬(A ∧ B) matches the column for ¬A ∨ ¬B in all four rows.
可以通过为两边分别构建真值表来验证这些定律。例如,¬(A ∧ B) 的值与 ¬A ∨ ¬B 的值在全部四行中完全一致。
Other useful identities include double negation and absorption:
其他有用恒等式包括双重否定和吸收律:
-
¬(¬A) ≡ A
¬(¬A) ≡ A
-
A ∨ (A ∧ B) ≡ A
A ∨ (A ∧ B) ≡ A
-
A ∧ (A ∨ B) ≡ A
A ∧ (A ∨ B) ≡ A
12. Applications and Problem-Solving Tips | 应用与解题技巧
Logic gates and truth tables appear in IB questions related to digital logic, proof of equivalence, and simplification. One classic application is the half-adder circuit for binary addition, where the sum output is A ⊕ B and the carry output is A ∧ B.
逻辑门与真值表会出现在 IB 的与数字逻辑、等价性证明和化简相关的题目中。一个经典应用是二进制加法中的半加器电路,其中和输出为 A ⊕ B,进位输出为 A ∧ B。
When solving truth table problems, follow these tips:
解答真值表题目时,可参考以下技巧:
-
Always order input rows using binary counting, from 0 upward. This avoids duplicates and omissions.
始终使用二进制计数法对输入行排序,从 0 开始递增,以避免重复或遗漏。
-
Break a complex expression into small sub-expressions and evaluate each separately.
将复杂表达式拆分成若干小子表达式,分别求值。
-
If two expressions have the same truth table, they are logically equivalent. This is often used to prove identities.
如果两个表达式具有相同的真值表,则它们在逻辑上等价。这种方法常被用来
Published by TutorHao | IB Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导