📚 IGCSE Computer Science: Boolean Algebra | IGCSE 计算机:布尔代数 考点精讲
Boolean algebra is a fundamental branch of algebra where variables represent truth values (TRUE or FALSE, 1 or 0) and operations are based on logical reasoning. In IGCSE Computer Science, Boolean algebra underpins digital circuits, program logic, and search queries. Mastering it enables you to simplify logic expressions, design efficient circuits, and write better conditional code.
布尔代数是代数的一个基础分支,其中的变量表示真值(真或假,1 或 0),运算基于逻辑推理。在 IGCSE 计算机课程中,布尔代数支撑着数字电路、程序逻辑和搜索查询。掌握它能帮助你简化逻辑表达式、设计高效电路并编写更优的条件代码。
1. Boolean Values and Variables | 布尔值与变量
Boolean variables can only take one of two values: TRUE (1) or FALSE (0). In logic diagrams and truth tables, 1 represents a HIGH voltage or TRUE condition, while 0 represents LOW or FALSE.
布尔变量只能取两个值之一:真(1)或假(0)。在逻辑图和真值表中,1 表示高电平或真条件,0 表示低电平或假。
In programming, Boolean variables are used to control the flow of execution through if-statements and loops. For example, a variable isRaining might be set to TRUE or FALSE.
在编程中,布尔变量用于通过 if 语句和循环控制执行流程。例如,变量 isRaining 可被设为真或假。
2. Basic Logic Gates: AND, OR, NOT | 基本逻辑门:与、或、非
The three fundamental gates are AND, OR, and NOT. An AND gate outputs 1 only if all inputs are 1. An OR gate outputs 1 if at least one input is 1. A NOT gate (inverter) reverses its single input: 1 becomes 0, and 0 becomes 1.
三个基本逻辑门是与门、或门和非门。与门仅在所有输入都为 1 时才输出 1。或门在至少一个输入为 1 时输出 1。非门(反相器)反转其单一输入:1 变 0,0 变 1。
The symbols for these gates are standardised in IGCSE. The AND gate is a D-shape, the OR gate is a curved shield shape, and the NOT gate is a triangle with a small circle at the tip.
这些门的符号在 IGCSE 中是标准化的。与门为 D 形,或门为弯曲的盾形,非门为尖端带小圆的三角形。
| Gate | Symbol (brief) | Truth Table |
|---|---|---|
| AND | D-shape | 00→0, 01→0, 10→0, 11→1 |
| OR | Shield shape | 00→0, 01→1, 10→1, 11→1 |
| NOT | Triangle + circle | 0→1, 1→0 |
3. Truth Tables | 真值表
A truth table lists all possible input combinations and the resulting output for a given logic circuit or expression. It is an essential tool for analysis, verification, and simplification.
真值表列出了给定逻辑电路或表达式的所有可能输入组合及其对应输出。它是分析、验证和化简的重要工具。
To construct a truth table, begin by determining the number of input variables. For n inputs, there are 2n rows. Label each column clearly, and systematically fill in binary counts for the inputs.
要构建真值表,首先确定输入变量的数量。对于 n 个输入,共有 2n 行。清楚标记每一列,并系统地按二进制计数填充输入值。
gate has 4 rows: A=0, B=0; A=0, B=1; A=1, B=0; A=1, B=1. The output column shows 0,0,0,1.
例如,二输入与门有 4 行:A=0, B=0;A=0, B=1;A=1, B=0;A=1, B=1。输出列显示 0,0,0,1。
4. Boolean Expressions and Notation | 布尔表达式与记法
Boolean expressions use operators to combine variables: AND is represented by a dot (·) or simply juxtaposition (AB), OR by a plus (+), and NOT by an overbar (¬) or a prime (A'). For IGCSE, the overbar is common: A̅ means NOT A.
布尔表达式使用运算符组合变量:与用点号(·)或直接并列(AB),或用加号(+),非用上划杠(¬)或撇号(A')。IGCSE 中常用上杠:A̅ 表示非 A。
Expression evaluation follows operator precedence: NOT has the highest priority, then AND, then OR. Parentheses override this order, just like in ordinary algebra.
表达式计算遵循运算符优先级:非优先级最高,其次是与,最后是或。括号可以覆盖该顺序,就像普通代数一样。
Example: The expression Y = A·B + C̅ means (A AND B) OR (NOT C).
示例:表达式 Y = A·B + C̅ 表示 (A 与 B) 或 (非 C)。
5. Logic Circuit Diagrams | 逻辑电路图
Logic circuits are drawn using gate symbols connected by lines representing signals. The flow is typically from left (inputs) to right (output). You must be able to draw a circuit from an expression and vice versa.
逻辑电路使用逻辑门符号绘制,通过代表信号的导线连接。流程通常从左(输入)到右(输出)。你必须能根据表达式画出电路,反之亦然。
For Y = A̅·B + A·B̅, you would draw two NOT gates for A and B, two AND gates for the terms, and an OR gate combining them. This is an XOR function.
对于 Y = A̅·B + A·B̅,你需要为 A 和 B 画两个非门,为各项画两个与门,再用一个或门组合它们。这便是异或函数。
When interpreting a circuit, start from the leftmost inputs, trace each path, apply gate operations, and build the final Boolean expression.
解读电路时,从最左侧的输入开始,追踪每条路径,应用门运算,构建最终的布尔表达式。
6. NAND and NOR as Universal Gates | 与非门和或非门作为通用门
NAND (NOT AND) and NOR (NOT OR) are called universal gates because any other gate can be constructed using only NAND gates or only NOR gates. NAND outputs 0 only when all inputs are 1; NOR outputs 1 only when all inputs are 0.
与非门(非与)和或非门(非或)被称为通用门,因为仅用与非门或仅用或非门就能构建任何其他门。与非门仅在所有输入为 1 时输出 0;或非门仅在所有输入为 0 时输出 1。
Using NAND gates: a NOT gate is made by joining the inputs of a NAND; an AND gate is a NAND followed by a NOT (which is another NAND). This property is crucial in chip design for reducing manufacturing costs.
使用与非门:将与非门的输入连接起来可以构成非门;与门是非门加非门(即另一个与非门)。这一特性在芯片设计中对于降低制造成本至关重要。
| Gate | NAND equivalent | NOR equivalent |
|---|---|---|
| NOT | NAND with inputs tied | NOR with inputs tied |
| AND | NAND + NAND (as NOT) | 3 NOR gates |
| OR | 3 NAND gates | NOR + NOR (as NOT) |
7. XOR and XNOR Gates | 异或门和同或门
A ≠ B. The XNOR (Exclusive NOR) gate outputs 1 when A = B, i.e., it is the inverse of XOR.
异或门在输入中有奇数个 1 时输出 1。对于两个输入,当 A ≠ B 时输出 1。同或门在 A = B 时输出 1,即异或门的反相。
XOR is often used in arithmetic circuits like half-adders and full-adders. Its Boolean expression can be written as A⊕B = A̅·B + A·B̅.
异或常用于半加器和全加器等算术电路。其布尔表达式可写为 A⊕B = A̅·B + A·B̅。
Truth table for XOR (2-input): 0⊕0=0, 0⊕1=1, 1⊕0=1, 1⊕1=0. For XNOR: 0⊙0=1, 0⊙1=0, 1⊙0=0, 1⊙1=1.
二输入异或真值表:0⊕0=0,0⊕1=1,1⊕0=1,1⊕1=0。同或:0⊙0=1,0⊙1=0,1⊙0=0,1⊙1=1。
8. Laws of Boolean Algebra | 布尔代数定律
Boolean algebra is governed by a set of laws that allow simplification of expressions. Key laws include Commutative, Associative, Distributive, Identity, Complement, and Idempotent laws.
布尔代数由一组定律支配,允许化简表达式。关键定律包括交换律、结合律、分配律、同一律、互补律和幂等律。
- 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·B + A·C; A+(B·C) = (A+B)·(A+C)
- Identity Law 同一律: A+0 = A; A·1 = A
- Complement Law 互补律: A + A̅ = 1; A·A̅ = 0
- Idempotent Law 幂等律: A+A = A; A·A = A
De Morgan's Laws are especially important for converting between AND/OR and NAND/NOR forms: (A+B)̅ = A̅ · B̅ and (A·B)̅ = A̅ + B̅.
德摩根定律对于在 AND/OR 和 NAND/NOR 形式之间转换尤为重要:(A+B)̅ = A̅ · B̅ 以及 (A·B)̅ = A̅ + B̅。
9. Simplifying Logic Expressions | 化简逻辑表达式
Simplification reduces the number of gates and inputs required in a circuit, lowering cost and power consumption. The two main methods are algebraic manipulation using Boolean laws and the Karnaugh map (K-map) method.
化简可减少电路所需门数和输入数,降低成本和功耗。两种主要方法是利用布尔定律进行代数化简和卡诺图化简法。
Algebraic simplification example: Y = A·B + A·B̅ factors to A·(B + B̅) = A·1 = A. The circuit reduces from two AND gates and one OR gate to a simple wire!
代数化简示例:Y = A·B + A·B̅ 提取公因式得 A·(B + B̅) = A·1 = A。电路从两个与门、一个或门简化为一条导线!
For IGCSE, students are expected to simplify straightforward expressions by spotting common factors and applying complement and identity laws. Always check your result with a truth table.
IGCSE 学生需要能够通过找出公因子、应用互补律和同一律来化简简单表达式。务必用真值表验证结果。
10. Karnaugh Maps (K-maps) Overview | 卡诺图概述
A Karnaugh map is a visual tool for simplifying Boolean expressions of up to four variables. It arranges truth table minterms in a grid so that adjacent cells differ by only one variable, enabling easy grouping of 1s.
卡诺图是一种用于化简最多四个变量的布尔表达式的可视化工具。它将真值表中的最小项排列成网格,使得相邻单元格只有一个变量不同,便于将 1 分组。
able and columns by the other. You fill in each cell with the output from the truth table.
对于二变量卡诺图,网格为 2×2,行以一个变量标记,列以另一个变量标记。用真值表的输出值填充每个单元格。
Groups of 1s must be rectangular and size must be a power of 2 (1,2,4,8). The goal is to cover all 1s with the fewest, largest groups. Overlapping groups are allowed. Each group corresponds to a product term where a variable is eliminated if it changes within the group.
1 的分组必须是矩形,大小必须为 2 的幂(1,2,4,8)。目标是用最少、最大的组覆盖所有 1。组可以重叠。每组对应一个乘积项,如果某变量在组内发生了变化,则该变量会被消去。
11. Applying K-maps to Simplify | 应用卡诺图进行化简
Example: simplify Y = A̅·B̅ + A̅·B + A·B̅ . The K-map shows three 1s that can be grouped as two 2-cell groups: one covering column B̅ and one covering row A̅.
示例:化简 Y = A̅·B̅ + A̅·B + A·B̅。真值表产生 00→1,01→1,10→1,11→0。卡诺图显示三个 1,可分组为两个二单元格组:一个覆盖 B̅ 列,一个覆盖 A̅ 行。
From the group covering when A=0 (row A̅), we get A̅. From the group covering when B=0 (column B̅), we get B̅. Therefore, Y simplifies to A̅ + B̅, which is a NAND gate by De Morgan: (A·B)̅.
从覆盖 A=0(A̅ 行)的组,我们得到 A̅。从覆盖 B=0(B̅ 列)的组,我们得到 B̅。因此,Y 化简为 A̅ + B̅,由德摩根定律可知它是与非门:(A·B)̅。
Always verify the simplified expression by building a truth table for both the original and simplified forms; they must match exactly.
始终通过为原始形式和化简形式构建真值表来验证;它们必须完全匹配。
12. Boolean Algebra in Programming and Problem Solving | 编程与问题求解中的布尔代数
Boolean logic appears in if-else conditions, while loops, and database queries. Understanding Boolean algebra helps you write more efficient and readable code by minimising complex conditional statements.
布尔逻辑出现在 if-else 条件、while 循环和数据库查询中。理解布尔代数有助于通过简化复杂的条件语句来编写更高效、更易读的代码。
For instance, the expression if (!(A && B) && (A || B)) can be simplified using De Morgan's and Boolean laws to if (A ^ B) (XOR). This reduces confusion and potential bugs.
例如,表达式 if (!(A && B) && (A || B)) 可以使用德摩根定律和布尔定律简化为 if (A ^ B)(异或)。这减少了混淆和潜在错误。
Search engines use Boolean operators to refine queries. Knowledge of AND, OR, NOT allows you to construct precise search strings, a practical cross-curricular skill.
搜索引擎使用布尔运算符来优化查询。掌握 AND、OR、NOT 可以让你构建精确的搜索字符串,这是一项实用的跨学科技能。
Published by TutorHao | IGCSE Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

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