Boolean Logic Operations and Logic Gates Basics | 布尔逻辑运算与逻辑门基础

📚 Boolean Logic Operations and Logic Gates Basics | 布尔逻辑运算与逻辑门基础

Boolean logic is the foundation of all digital computing. Every operation performed by a computer, from simple arithmetic to complex decision-making, is ultimately reduced to combinations of Boolean values: true and false, represented in binary as 1 and 0.

布尔逻辑是所有数字计算的基石。计算机执行的每一次操作,从简单的算术到复杂的决策,最终都会被简化为布尔值的组合:真与假,在二进制中分别表示为 1 和 0。

In the CIE Computer Science syllabus, students must understand how Boolean expressions are evaluated, how logic gates operate, and how these gates combine to form functional circuits. This article provides a complete guide to Boolean logic operations and logic gate fundamentals, with truth tables and exam-focused explanations.

在 CIE 计算机科学考纲中,学生需要理解布尔表达式如何求值、逻辑门如何运作,以及这些门如何组合形成功能性电路。本文提供了布尔逻辑运算与逻辑门基础的完整指南,包含真值表和紧扣考点的讲解。


1. What is Boolean Logic | 什么是布尔逻辑

Boolean logic is a branch of algebra developed by mathematician George Boole in the 19th century. Unlike conventional algebra where variables can hold many values, Boolean variables can only hold one of two possible values: TRUE (1) or FALSE (0).

布尔逻辑是由数学家乔治·布尔在 19 世纪发展出的代数分支。与传统代数中变量可以取多个值不同,布尔变量只能取两个可能值之一:真(1)或假(0)。

This binary nature makes Boolean logic perfectly suited to digital electronics, where electrical signals are either high voltage (representing 1) or low voltage (representing 0). The entire structure of modern computers — processors, memory, and storage — relies on Boolean operations.

这种二值特性使得布尔逻辑完美适用于数字电子学,其中电信号要么是高电压(表示 1),要么是低电压(表示 0)。现代计算机的整个结构——处理器、内存和存储——都依赖于布尔运算。

In the CIE syllabus, three fundamental operators are introduced first: AND, OR and NOT. From these, more complex gates such as NAND, NOR, XOR and XNOR are derived.

在 CIE 考纲中,首先引入三个基本运算符:AND(与)、OR(或)和 NOT(非)。在此基础上,推导出更复杂的门电路,如 NAND(与非)、NOR(或非)、XOR(异或)和 XNOR(同或)。


2. Boolean Values and Operators | 布尔值与运算符

Each Boolean operator has a distinct mathematical symbol and a corresponding logic gate representation. The table below summarises the three basic operators:

每个布尔运算符都有独特的数学符号和对应的逻辑门表示。下表总结了三个基本运算符:

Operator Symbol Expression English Description
AND · (dot) A·B TRUE only when both inputs are TRUE
OR + (plus) A+B TRUE when at least one input is TRUE
NOT ¬ (negation) ¬A Inverts the input value

Notice that AND uses the same symbol as multiplication (·) and OR uses the same symbol as addition (+). This is intentional; Boolean algebra follows rules structurally similar to ordinary algebra, which makes manipulation and simplification of expressions more intuitive.

注意 AND 使用与乘法相同的符号(·),OR 使用与加法相同的符号(+)。这是有意为之;布尔代数遵循与普通代数结构相似的规则,这使得表达式的运算和化简更加直观。

The NOT operator is a unary operator, meaning it operates on a single input. In many textbooks, ¬A is also written as A’ (A-prime) or as an overline: Ā. In examination papers, all three notations may appear, so you must recognise them all.

NOT 运算符是单目运算符,即它只对单个输入进行操作。在许多教科书中,¬A 也写作 A’(A 撇)或 A 上方的横线:Ā。在考试试卷中,三种记法都可能出现,因此你必须都能识别。


3. Truth Tables | 真值表

A truth table is a systematic way of listing all possible input combinations for a logic circuit and the corresponding output for each combination. For a circuit with n inputs, the truth table will have 2ⁿ rows of input combinations.

真值表是系统地列出逻辑电路所有可能的输入组合以及每种组合对应输出的方法。对于有 n 个输入的电路,真值表将有 2ⁿ 行输入组合。

For example, a two-input logic gate has four possible input combinations: 00, 01, 10 and 11. In a truth table, inputs are typically written in binary order from bottom to top, though in the CIE syllabus top-to-bottom ascending order (00, 01, 10, 11) is standard.

例如,一个双输入逻辑门有四种可能的输入组合:00、01、10 和 11。在真值表中,输入通常从下到上按二进制顺序排列,但在 CIE 考纲中,采用从上到下的升序排列(00、01、10、11)是标准做法。

Truth tables are essential in examination questions for several reasons: they demonstrate an understanding of gate behaviour, they are used to derive Boolean expressions from circuits, and they verify that a simplified expression is equivalent to the original one.

真值表在考试题目中至关重要,原因有以下几点:它们展示了考生对门电路行为的理解,它们被用于从电路中推导布尔表达式,并且它们用于验证化简后的表达式是否与原表达式等价。


4. The AND Gate | 与门

The AND gate produces an output of 1 only when all of its inputs are 1. If any input is 0, the output is 0. For two inputs A and B, the Boolean expression is written as:

与门仅当其所有输入都为 1 时,输出才为 1。如果有任何输入为 0,输出即为 0。对于两个输入 A 和 B,布尔表达式写作:

X = A · B

A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1

The AND gate can be extended to three or more inputs. A three-input AND gate outputs 1 only when A = 1, B = 1 and C = 1 simultaneously. The logic remains the same regardless of the number of inputs.

与门可以扩展到三个或更多输入。一个三输入与门仅在 A = 1、B = 1 且 C = 1 同时成立时输出 1。无论输入数量多少,逻辑都是一样的。

A common real-world analogy is a series circuit with two switches: the lamp only turns on when both switches are closed. In computer systems, AND gates are used in data masking and condition checking.

一个常见的现实类比是带两个开关的串联电路:只有当两个开关都闭合时,灯才会亮。在计算机系统中,与门用于数据掩码和条件检查。


5. The OR Gate | 或门

The OR gate produces an output of 1 when at least one of its inputs is 1. The output is 0 only when all inputs are 0. For two inputs A and B, the Boolean expression is:

或门在其至少一个输入为 1 时输出 1。仅当所有输入都为 0 时,输出才为 0。对于两个输入 A 和 B,布尔表达式为:

X = A + B

A B A OR B
0 0 0
0 1 1
1 0 1
1 1 1

An important distinction in computer science is the difference between inclusive OR and exclusive OR. The standard OR gate is inclusive: it outputs 1 when both inputs are 1. The XOR gate, which we will examine later, excludes this case.

在计算机科学中,一个重要的区别是包含式 OR 与排除式 OR(异或)之间的差异。标准的 OR 门是包含式的:当两个输入都为 1 时,它输出 1。而后面将要讨论的 XOR 门则排除了这种情况。

A parallel circuit with two switches demonstrates OR behaviour: the lamp turns on if either switch is closed, or both. In programming, OR is used to combine conditions — for example, checking if a user is an admin OR a moderator.

带有两个开关的并联电路演示了 OR 行为:只要任一开关闭合或两个都闭合,灯就会亮。在编程中,OR 用于组合条件——例如,检查用户是否为管理员或版主。


6. The NOT Gate | 非门

The NOT gate, also called an inverter, has a single input and a single output. It flips the input value: a 0 becomes a 1, and a 1 becomes a 0. The Boolean expression is:

非门,也称为反相器,有一个输入和一个输出。它将输入值翻转:0 变为 1,1 变为 0。布尔表达式为:

X = ¬A

A NOT A (¬A)
0 1
1 0

Applying the NOT gate twice returns the original value: ¬(¬A) = A. This property is known as double negation and is frequently tested in simplification exercises.

对同一输入应用两次非门会恢复原始值:¬(¬A) = A。这一性质被称为双重否定,在化简练习题中经常出现。

In circuit diagrams, the NOT gate is drawn as a triangle pointing to the right with a small circle (bubble) at its output. This bubble notation is important — a bubble at the output of any gate indicates inversion.

在电路图中,非门绘制为一个指向右侧的三角形,其输出端带有一个小圆圈(气泡)。这种气泡记法非常重要——任何门输出端的圆圈都表示取反。


7. The NAND Gate | 与非门

The NAND gate is the combination of an AND gate followed by a NOT gate. Its output is the exact inverse of the AND gate: it outputs 0 only when all inputs are 1, and outputs 1 in all other cases. The expression is:

与非门是与门后接非门的组合。其输出正好与门相反:仅当所有输入都为 1 时输出 0,其余所有情况输出 1。表达式为:

X = ¬(A · B)

A B A NAND B
0 0 1
0 1 1
1 0 1
1 1 0

NAND gates are particularly significant in digital electronics because they are functionally complete. This means any other logic gate (AND, OR, NOT, NOR, XOR, XNOR) can be constructed using only NAND gates. This property dramatically simplifies manufacturing, as chip fabricators only need to produce one type of gate.

与非门在数字电子中特别重要,因为它们在功能上是完备的。这意味着任何其他逻辑门(与门、或门、非门、或非门、异或门、同或门)都可以仅使用与非门来构建。这一特性极大地简化了制造过程,芯片制造商只需生产一种类型的门即可。

Exam tip: you may be asked to draw a NOT gate using only NAND gates. The solution is to connect both inputs of the NAND gate together, so that A NAND A = ¬A.

考试提示:你可能被要求仅使用与非门来画一个非门。解决方案是将与非门的两个输入连接在一起,因为 A NAND A = ¬A。


8. The NOR Gate | 或非门

The NOR gate is the combination of an OR gate followed by a NOT gate. Its output is the inverse of the OR gate: it outputs 1 only when all inputs are 0, and outputs 0 in all other cases. The expression is:

或非门是或门后接非门的组合。其输出与或门相反:仅当所有输入都为 0 时输出 1,其余所有情况输出 0。表达式为:

X = ¬(A + B)

A B A NOR B
0 0 1
0 1 0
1 0 0
1 1 0

Like the NAND gate, the NOR gate is also functionally complete. Every Boolean function can be implemented using only NOR gates. For example, a NOT gate can be made from a single NOR gate by joining its inputs: A NOR A = ¬A.

与非门一样,或非门也是功能完备的。每个布尔函数都可以仅使用或非门来实现。例如,可以通过连接或非门的两个输入来构成非门:A NOR A = ¬A。

In the CIE syllabus, students should memorise the truth tables for both NAND and NOR gates and be able to draw their circuit symbols, which are the AND and OR gate shapes with a bubble at the output.

在 CIE 考纲中,学生应熟记与非门和或非门的真值表,并能够绘制它们的电路符号,即在与门和或门形状的输出端加一个气泡。


9. The XOR and XNOR Gates | 异或门与同或门

The XOR (exclusive OR) gate outputs 1 when the inputs are different, and 0 when the inputs are the same. In other words, it produces 1 only when exactly one of the two inputs is 1. The expression is:

异或门在输入不同时输出 1,在输入相同时输出 0。换句话说,仅当两个输入中恰好有一个为 1 时,它输出 1。表达式为:

X = A ⊕ B = ¬A·B + A·¬B

A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0

XOR has a crucial application in arithmetic: it forms the core of binary addition. When two bits are added, the sum bit is given by A XOR B, while the carry bit is given by A AND B. A half-adder circuit is constructed from exactly these two gates.

异或运算在算术中有重要应用:它构成了二进制加法的核心。当两个比特相加时,和位由 A XOR B 给出,而进位位由 A AND B 给出。半加器电路正是由这两个门构成的。

The XNOR gate is the inverse of XOR: it outputs 1 when the inputs are the same, and 0 when they differ. Its expression is X = A ⊙ B = ¬(A ⊕ B). The XNOR gate is sometimes called the equality gate because it detects whether two inputs are equal.

同或门是异或门的反相:当输入相同时输出 1,不同时输出 0。其表达式为 X = A ⊙ B = ¬(A ⊕ B)。同或门有时被称为相等门,因为它检测两个输入是否相等。

A B A XNOR B
0 0 1
0 1 0
1 0 0
1 1 1

In circuit symbols, XOR is drawn like an OR gate with an extra curved line at the input side, and XNOR adds a bubble at the output.

在电路符号中,异或门的画法类似或门但在输入侧多了一条弧形线,同或门则在输出端加一个气泡。


10. Boolean Algebra Rules | 布尔代数规则

Boolean algebra provides a set of rules for simplifying logic expressions. These laws are essential for minimising circuits, which reduces cost and power consumption in real hardware. The most important rules are listed below.

布尔代数提供了一组用于化简逻辑表达式的规则。这些定律对于最小化电路至关重要,可以降低实际硬件中的成本和功耗。最重要的规则如下所列。

Identity Laws | 恒等律

A + 0 = A    A · 1 = A

Adding 0 or multiplying by 1 leaves the variable unchanged; 0 is the identity for OR, and 1 is the identity for AND.

加 0 或乘 1 不改变变量的值;0 是 OR 的恒等元素,1 是 AND 的恒等元素。

Null Laws | 零律

A + 1 = 1    A · 0 = 0

OR-ing with 1 always gives 1; AND-ing with 0 always gives 0, regardless of the value of A.

与 1 进行 OR 运算结果恒为 1;与 0 进行 AND 运算结果恒为 0,无论 A 的值是什么。

Idempotent Laws | 幂等律

Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading