Paper 2 · Logic 试卷二 · 逻辑

10 · Boolean logic

10 · 布尔逻辑

Logic gates, circuits and truth tables

逻辑门、电路与真值表

Six gates, each turning binary inputs into a binary output. From there the whole topic is moving between four forms of the same thing: a problem statement, a logic expression, a logic circuit, and a truth table.

六种逻辑门,每一种都把二进制输入转换成一个二进制输出。在此基础上,整个主题都是在同一事物的四种形式之间转换:一个问题陈述、一个逻辑表达式、一个逻辑电路,以及一张真值表。

Core for all candidates 所有考生均需掌握的核心内容 Covers 10.1, 10.2, 10.3 涵盖 10.1、10.2、10.3 Its own Paper 2 question, every series 每一季试卷二都有独立的一道题

Explainer · 10.1 + 10.2

讲解 · 10.1 + 10.2

The six logic gates

六种逻辑门

A logic gate takes one or two binary inputs (0 or 1) and produces one binary output. The 0478 syllabus uses six, each with its own standard symbol and its own rule. NOT has one input; the other five have two.

逻辑门接收一个或两个二进制输入(0 或 1),并产生一个二进制输出。0478 考纲使用六种逻辑门,每一种都有自己的标准符号和规则。NOT 有一个输入;其余五种都有两个。

!Markers report the XOR symbol drawn wrongly more than any other, and NOR / XOR drawn with straight sides so they look like a NOT gate. Each gate must keep its own distinctive shape: AND has a flat back, OR and XOR a curved back and a pointed front, XOR has the extra curved line behind it, and a small circle on the output means the result is inverted (NAND, NOR, NOT).

!考官报告称,XOR 符号被画错的次数比其他任何符号都多,而 NOR / XOR 有时被画成直边,看起来像 NOT 门。每种门都必须保持自己独特的形状:AND 后背是平的,OR 和 XOR 后背是弧形、前端是尖的,XOR 在后面多了一条弧线,输出端的小圆圈表示结果被取反(NAND、NOR、NOT)。

Try it yourself

动手试试

A live logic circuit

一个实时逻辑电路

This circuit is X = (A AND B) OR (NOT C). Click A, B and C to flip them between 0 and 1. Wires carrying a 1 light up, and the output X and the highlighted truth-table row update as you go.

这个电路是 X = (A AND B) OR (NOT C)。点击 A、B 和 C 在 0 与 1 之间切换。承载 1 的导线会亮起,输出 X 以及高亮显示的真值表行会随之更新。

ABCA AND BNOT CX

Every one of the 8 input rows is here because a 3-input circuit has 23 = 8 combinations. A truth table always lists them all, counting up in binary.

这里列出全部 8 行输入,是因为一个三输入的电路共有 23 = 8 种组合。真值表总是把它们全部列出,按二进制递增排列。

Explainer · 10.3(b)

讲解 · 10.3(b)

Building a truth table from a circuit or expression

从电路或表达式构建真值表

For anything bigger than one gate, work it in parts. Give each gate’s output a letter (P, Q), fill a column for each, then combine. Here is X = (A OR NOT B) AND (B NAND C) worked in full.

对于超过一个门的电路,要分部分处理。给每个门的输出取一个字母(P、Q),为每个字母填一列,然后再组合。下面是 X = (A OR NOT B) AND (B NAND C) 的完整推导。

  1. P = A OR NOT B. NOT B is 1 whenever B is 0, so P is 0 only on the rows where A is 0 and B is 1.
  2. Q = B NAND C. NAND is 1 unless both inputs are 1, so Q is 0 only where B and C are both 1.
  3. X = P AND Q. 1 only where P and Q are both 1.
  1. P = A OR NOT B。只要 B 为 0,NOT B 就为 1,所以只有在 A 为 0 且 B 为 1 的行中,P 才为 0。
  2. Q = B NAND C。除非两个输入都为 1,否则 NAND 为 1,所以只有 B 和 C 都为 1 时,Q 才为 0。
  3. X = P AND Q。只有 P 和 Q 都为 1 时才为 1。
ABCP = A OR NOT BQ = B NAND CX = P AND Q
000111
001111
010010
011000
100111
101111
110111
111100

The intermediate columns can be dropped once you are confident, leaving just A, B, C and X. Leaving them in is how you earn method marks and catch your own errors.

一旦有把握,中间列就可以省略,只留下 A、B、C 和 X。保留它们是你获得方法分、并发现自己错误的方式。

Explainer · 10.3(a) + 10.3(c)

讲解 · 10.3(a) + 10.3(c)

Moving between statement, expression and circuit

在陈述、表达式与电路之间转换

Problem statement → expression

问题陈述 → 表达式

A greenhouse fan turns on (X = 1) if the temperature is high (A) and the window is closed (B); or if the humidity is high (C) and the window is closed (B).

温室风扇会开启(X = 1),如果温度高(A)且窗户关闭(B);或者湿度高(C)且窗户关闭(B)。

  1. “temperature high AND window closed” → A AND B
  2. “humidity high AND window closed” → C AND B
  3. the two conditions are joined by “or” → OR
  1. "温度高且窗户关闭" → A AND B
  2. "湿度高且窗户关闭" → C AND B
  3. 这两个条件由"或"连接 → OR
(A AND B) OR (C AND B)

Then the circuit is drawn straight from that: an AND gate for each bracket, both feeding one OR gate. Do not tidy it to B AND (A OR C) first: the syllabus and the mark scheme want the circuit drawn for the statement as given, without simplification.

然后直接依据它画出电路:每个括号对应一个 AND 门,两者都输入到同一个 OR 门。不要先把它简化为 B AND (A OR C):考纲和评分标准都要求按给定的陈述画出电路,不要先化简。

Circuit → expression

电路 → 表达式

Read the gates touching the inputs first, then work outwards. A circuit with an OR gate on A, B and a NAND gate on B, C, both feeding a final AND gate:

先读懂与输入直接相连的门,再向外推进。一个电路中,A、B 接入一个 OR 门,B、C 接入一个 NAND 门,两者都输入到最后的 AND 门:

  1. first gate: A OR B
  2. second gate: B NAND C
  3. final gate joins them: AND
  1. 第一个门:A OR B
  2. 第二个门:B NAND C
  3. 最后的门把它们连接起来:AND
(A OR B) AND (B NAND C)

Truth table → expression

真值表 → 表达式

Look only at the rows where the output is 1. Write each as a set of inputs joined by AND (using NOT for a 0), then join those with OR.

只看输出为 1 的那些行。把每一行写成一组由 AND 连接的输入(0 用 NOT 表示),再用 OR 把这些连接起来。

ABX
001
011
100
110
  1. A = 0, B = 0 gives X = 1 → NOT A AND NOT B
  2. A = 0, B = 1 gives X = 1 → NOT A AND B
  3. join the output-1 rows with OR
  1. A = 0,B = 0 时 X = 1 → NOT A AND NOT B
  2. A = 0,B = 1 时 X = 1 → NOT A AND B
  3. 用 OR 把这些输出为 1 的行连接起来
(NOT A AND NOT B) OR (NOT A AND B)

The rows where X is 0 are ignored. Every row where X is 1 adds one bracket. This one happens to be equivalent to just NOT A, but write out both output-1 rows: the syllabus wants the expression taken straight from the table, without simplification.

X 为 0 的行被忽略。每一行 X 为 1 就增加一个括号。这个例子恰好等价于 NOT A,但仍要把两个输出为 1 的行都写出来:考纲要求表达式直接从表中得出,不要先化简。

Check your understanding

检验你的理解

For X = (A OR B) AND NOT C, what is X when A = 0, B = 1, C = 0?

对于 X = (A OR B) AND NOT C,当 A = 0、B = 1、C = 0 时,X 的值是多少?

Check your understanding

检验你的理解

A circuit feeds A and B into an AND gate, then that output and C into an OR gate. Which is the correct logic expression?

一个电路把 A 和 B 输入一个 AND 门,再把该输出与 C 一起输入一个 OR 门。哪一个是正确的逻辑表达式?

Check your understanding

检验你的理解

Which logic expression does this truth table represent?

这张真值表代表哪一个逻辑表达式?

ABCX
0000
0010
0101
0110
1000
1011
1100
1110

Common mistakes

常见错误

Markers reported these patterns for 10.1 / 10.2 / 10.3 考官针对 10.1 / 10.2 / 10.3 报告了以下模式

RecurringOn the symbols, markers reported the XOR gate drawn in many wrong variations, and NOR / XOR drawn with straight sides and a curved back so they could be mistaken for a NOT gate. Every gate must keep its own distinctive shape.

反复出现在符号方面,考官报告称 XOR 门被画成许多种错误的变体,而 NOR / XOR 有时被画成直边加弧形后背,导致与 NOT 门混淆。每种门都必须保持自己独特的形状。

On writing an expression, two recurring errors: putting X = at the front of the answer when only the expression itself is wanted, and writing A NOT instead of NOT A. NOT goes in front of the input it inverts.

在写表达式方面,有两处反复出现的错误:在只要求表达式本身时,却在答案前加上 X =;以及写成A NOT 而不是 NOT A。NOT 要放在它所取反的输入前面。

On drawing a circuit from an expression, candidates who simplified or rearranged the logic first lost marks. Draw exactly what the expression says, one gate per operator, even if part of it looks redundant.

在根据表达式画电路方面,先化简或重新排列逻辑的考生会失分。要严格按照表达式所写的画出来,每个运算符对应一个门,即使其中一部分看起来是多余的。

✕

Expression with a prefix: answering “write a logic expression for this circuit” with X = A NAND B.

带前缀的表达式:对"为这个电路写出逻辑表达式"这道题,回答 X = A NAND B。

✓

The expression only: A NAND B.

只写表达式: A NAND B。

✕

NOT after its input: A AND B NOT for “A and not B”.

NOT 放在输入之后:把"A 且非 B"写成 A AND B NOT。

✓

NOT in front: A AND NOT B.

NOT 放在前面: A AND NOT B。

✕

Simplified first: given (A AND B) OR (C AND B), drawing a single AND gate fed by B and an (A OR C) gate.

先化简:给定 (A AND B) OR (C AND B),却画出一个由 B 和一个 (A OR C) 门输入的单个 AND 门。

✓

Drawn as written: two AND gates (one for each bracket) both feeding one OR gate.

按原样画出:两个 AND 门(每个括号一个),都输入到同一个 OR 门。

Revision questions

复习题

Past-paper style. Write an answer, then reveal the marking points and mark yourself.

采用历年真题风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 2 marks 第 1 题 · 2 分

[2]Complete the output column of a truth table for X = A NOR B.

[2]补全 X = A NOR B 真值表的输出列。

Question 2 · 1 mark 第 2 题 · 1 分

[1]State how many input combinations a truth table has for a circuit with three inputs.

[1]陈述一个具有三个输入的电路,其真值表共有多少种输入组合。

Question 3 · 3 marks 第 3 题 · 3 分

[3]Write a logic expression for a circuit that feeds A, B into a NAND gate and B, C into an OR gate, then both results into an AND gate.

[3]为一个电路写出逻辑表达式:该电路把 A、B 输入一个 NAND 门,把 B、C 输入一个 OR 门,再把两个结果都输入一个 AND 门。

Question 4 · 4 marks 第 4 题 · 4 分

[4]A door unlocks (X = 1) if a valid card is present (A = 1) and the alarm is off (B = 0), or if the manual override is on (C = 1). Write the logic expression.

[4]当有效卡片存在(A = 1)且警报关闭(B = 0),或手动超控开关开启(C = 1)时,门会解锁(X = 1)。写出逻辑表达式。

Question 5 · 4 marks 第 5 题 · 4 分

[4]Complete the truth table for X = (A OR B) AND NOT C.

[4]补全 X = (A OR B) AND NOT C 的真值表。

Flashcards

记忆卡片

Active recall for this topic’s key terms.

针对本主题关键术语的主动回忆练习。

Prototype render · content grounded in the Cambridge IGCSE 0478 syllabus (Topic 10 + section 4 gate symbols) and real 0478 examiner-report data · not yet wired to live routes