📚 Logic Gates and Truth Tables | 逻辑门与真值表
Logic gates are the fundamental building blocks of digital circuits, each performing a basic logical function based on Boolean algebra. In this article we explore the most common gates, how to represent their behaviour with truth tables, and how to combine them to analyse more complex logical statements. This topic bridges discrete mathematics, computer logic, and the reasoning skills required in the IB Mathematics curriculum, particularly when studying propositions and set theory.
逻辑门是数字电路的基本构建块,每一个都基于布尔代数执行基本的逻辑功能。本文将探讨最常见的逻辑门,如何用真值表表示其行为,以及如何组合它们来分析更复杂的逻辑命题。这一主题连接了离散数学、计算机逻辑以及IB数学课程(尤其是命题与集合论部分)所需的推理能力。
1. Introduction to Logic Gates | 逻辑门简介
A logic gate is a physical device or mathematical abstraction that takes one or more binary inputs and produces a single binary output. Inputs and outputs are limited to two possible values: 0 (false, low) and 1 (true, high). By connecting gates together, we can model any boolean expression or circuit. In mathematics, these correspond to logical connectives such as conjunction, disjunction and negation.
逻辑门是一种物理设备或数学抽象,它接受一个或多个二进制输入并产生一个二进制输出。输入和输出仅限于两个可能的值:0(假,低电平)和1(真,高电平)。通过将逻辑门连接起来,我们可以模拟任何布尔表达式或电路。在数学中,这些对应于逻辑连接词,如合取、析取和否定。
2. Basic Gates: AND, OR and NOT | 基本逻辑门:与门、或门和非门
The three simplest gates are AND, OR and NOT. The AND gate outputs 1 only when all inputs are 1; symbolically we write A ∧ B. The OR gate outputs 1 when at least one input is 1, represented as A ∨ B. The NOT gate has a single input and inverts it: ¬A. These operations form a functionally complete set, meaning any other truth function can be expressed using only these three.
最简单的三个逻辑门是与门、或门和非门。与门仅在所有输入均为1时输出1;符号记为 A ∧ B。或门在至少一个输入为1时输出1,表示为 A ∨ B。非门只有一个输入并将其取反:¬A。这些运算构成了一个功能完备集,这意味着仅使用这三种运算就可以表达任何其他的真值函数。
3. Truth Tables: Definition and Construction | 真值表:定义与构建
A truth table systematically lists all possible combinations of input values and the corresponding output for a logical expression. To construct one, first determine the number of input variables n; there will be 2ⁿ rows. Assign binary values in a pattern that covers every combination, then evaluate the output column by applying the relevant logical rules step by step.
真值表系统地列出了输入值的所有可能组合以及逻辑表达式对应的输出。构建真值表时,首先确定输入变量的个数 n;总共有 2ⁿ 行。以覆盖所有组合的模式分配二进制值,然后通过逐步应用相关的逻辑规则来计算输出列。
| A | B | A ∧ B | A ∨ B | ¬A |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 |
4. NAND and NOR Gates | 与非门和或非门
A NAND gate is an AND gate followed by a NOT; its output is 0 only when all inputs are 1. The Boolean expression is ¬(A ∧ B). A NOR gate combines OR and NOT, giving 1 only when all inputs are 0, written as ¬(A ∨ B). Both NAND and NOR are called universal gates because individually each can be used to build any other gate, which is a powerful concept in circuit design.
与非门是与门后面接一个非门;只有当所有输入都是1时,其输出才为0。布尔表达式为 ¬(A ∧ B)。或非门将或门和非门组合,仅在所有输入均为0时输出1,写作 ¬(A ∨ B)。与非门和或非门都被称为通用门,因为单独每一个都可以用来构建任何其他逻辑门,这是电路设计中一个强大的概念。
5. XOR and XNOR Gates | 异或门和同或门
The XOR (exclusive OR) gate outputs 1 when an odd number of inputs are 1. For two inputs, A XOR B (denoted A ⊕ B) is true if A and B differ. The XNOR (exclusive NOR) gate gives the opposite: it outputs 1 when A and B are the same. These gates appear frequently in arithmetic circuits and parity checking.
异或门(XOR)在输入中1的个数为奇数时输出1。对于两个输入,若 A 和 B 不同,则 A XOR B(记为 A ⊕ B)为真。同或门(XNOR)则给出相反的结果:当 A 和 B 相同时输出1。这些门经常出现在算术电路和奇偶校验中。
| A | B | A ⊕ B | A XNOR B |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
6. Combining Gates and Boolean Expressions | 组合逻辑门与布尔表达式
When gates are wired together, the overall behaviour is described by a compound Boolean expression. For instance, the circuit with AND and OR feeding into a NAND might be written as ¬((A ∧ B) ∨ C). Parentheses are essential to show the order of operations. Reading such expressions from a circuit diagram is a key skill, as is drawing a circuit from a given Boolean formula.
当逻辑门连接在一起时,整体行为由一个复合布尔表达式描述。例如,由与门和或门输入到一个与非门的电路可以写作 ¬((A ∧ B) ∨ C)。括号对于表明运算顺序至关重要。从电路图中读取这类表达式是一项关键技能,同样,根据给定的布尔公式绘制电路也很重要。
7. Truth Tables for Compound Statements | 复合命题的真值表
To build a truth table for a compound expression like (A ∨ B) ∧ ¬(A ∧ B), which is equivalent to XOR, you must work step by step. First add columns for A and B, then intermediate columns for A ∨ B, A ∧ B, and ¬(A ∧ B), and finally the main output. This structured method prevents errors and reveals the logical equivalence of different expressions.
为复合表达式如 (A ∨ B) ∧ ¬(A ∧ B)(等同于异或)建立真值表时,必须逐步进行。首先添加 A 和 B 的列,然后添加中间列,如 A ∨ B、A ∧ B 和 ¬(A ∧ B),最后是主输出列。这种结构化的方法可以防止错误,并揭示不同表达式之间的逻辑等价性。
| A | B | A ∨ B | A ∧ B | ¬(A ∧ B) | (A∨B) ∧ ¬(A∧B) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
8. Logical Equivalence and Simplification | 逻辑等价与化简
uivalent if their truth tables are identical. Using Boolean algebra laws such as De Morgan's theorems (¬(A ∧ B) = ¬A ∨ ¬B, and ¬(A ∨ B) = ¬A ∧ ¬ educes the number of gates needed, which is essential in both mathematics and engineering.
如果两个逻辑表达式的真值表完全相同,则它们是等价的。利用布尔代数定律,如德摩根定理(¬(A ∧ B) = ¬A ∨ ¬B,以及 ¬(A ∨ B) = ¬A ∧ ¬B)、吸收律和分配律,我们可以化简复杂的电路。化简能减少所需逻辑门的数量,这在数学和工程中都很重要。
9. Application in Propositions and Set Theory | 在命题与集合论中的应用
In IB Mathematics, logical connectives are studied alongside set operations. The AND gate corresponds to intersection (∩), OR to union (∪), and NOT to complement. Truth tables mirror membership tables, while logical equivalence translates into set identities. Understanding logic gates therefore deepens your grasp of abstract algebraic structures and proof techniques.
在IB数学中,逻辑连接词与集合运算一起学习。与门对应交集(∩),或门对应并集(∪),非门对应补集。真值表与成员表镜像对应,逻辑等价转化为集合恒等式。因此,理解逻辑门能加深你对抽象代数结构和证明技巧的掌握。
10. Common Mistakes and How to Avoid Them | 常见错误与避坑指南
A frequent error is misplacing parentheses or reading a circuit left-to-right without respecting operator precedence. Another is confusing inclusive OR with exclusive OR. Always double-check the number of rows in a truth table: for n inputs, any fewer than 2ⁿ rows means missing cases. Practice converting between circuit diagrams, Boolean expressions and truth tables until the translation becomes automatic.
一个常见错误是括号位置错误,或者从左到右读取电路时没有遵循运算优先级。另一个是混淆了包含性或与异或。务必仔细检查真值表的行数:对于n个输入,任何少于2ⁿ行的情况都意味着遗漏了组合。不断练习电路图、布尔表达式和真值表之间的转换,直到翻译变得自动化。
11. Logic Gates in Exam Questions | 考试中的逻辑门问题
Typical examination tasks ask you to complete a truth table for a given gate arrangement, identify a single gate equivalent to a combination, simplify a Boolean expression using algebra, or draw a circuit from a description. Always show intermediate columns in truth tables to earn method marks. Labelling the output of each gate in a diagram before writing an expression helps avoid errors.
典型的考试题目会要求你完成给定门电路的真值表,识别与某种组合等效的单个逻辑门,用代数化简布尔表达式,或根据描述绘制电路。在真值表中始终显示中间列以获得方法分。在写表达式之前,在电路图中给每个门的输出标上标签有助于避免出错。
12. Summary and Further Study | 总结与拓展学习
Mastery of logic gates and truth tables provides a foundation for more advanced topics such as Karnaugh maps, half-adders, full-adders, and sequential circuits. Even if you do not pursue computer science, the logical rigour developed here will enhance your mathematical reasoning across the IB syllabus. Keep practising with varied examples to build confidence.
掌握逻辑门和真值表为更高级的主题(如卡诺图、半加器、全加器以及时序电路)打下了基础。即使你不攻读计算机科学,在此培养的逻辑严谨性也会增强你在IB课程中的数学推理能力。通过多样化的练习来建立信心。
Published by TutorHao | Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图