First exams 2027 · SL & HL 2027 年首次开考 · SL 与 HL

A1.2.4 · Computer fundamentals

A1.2.4 · 计算机基础

Construct and Analyse Truth Tables

构建和分析真值表

A truth table lists every possible combination of inputs and the output for each one. It is the bridge between a problem in words, a Boolean expression and a logic circuit: all three describe the same table.

真值表列出输入的每一种可能组合,以及每一种组合对应的输出。它是一座桥,连接用文字描述的问题、布尔表达式和逻辑电路:这三者描述的是同一张表。

A1's guiding question asks what principles underpin how a computer works. A truth table is the complete, checkable specification of a piece of logic: nothing about the circuit's behaviour is left unsaid.

A1 的引导性问题问的是支撑计算机运行的原理。真值表是一段逻辑的完整、可核对的规格说明:关于这个电路的行为,没有任何一点被漏掉。

Core for SL & HL SL 与 HL 核心内容 Typically 2–6 marks · AO3 通常 2–6 分 · AO3 Command term: construct, analyse 命令词:construct(构建)、analyse(分析)

Explainer

讲解

Four forms of one thing

同一件事的四种形式

Df

A truth table has one column per input, one column per output (and often extra columns for the outputs of gates partway through), and one row for every possible combination of input values.

真值表每个输入一列,每个输出一列(通常还给中途各个门的输出加额外的列),并且输入值的每一种可能组合占一行。

FormWhat it looks likeThis statement asks you to
Problem descriptionA sentence: "the alarm sounds if the system is armed and either sensor trips"Pick the gates it implies
Boolean expressionX = A · (B + C)Read it, and build its truth table
Logic circuitGates joined by wiresTrace it row by row to a truth table
Truth tableEvery input row and the output for eachUse it to simplify the expression or design the circuit
形式它长什么样本条考纲要求你
问题描述一句话:"当系统已布防、并且任一传感器被触发时,警报响起"选出它所暗示的门
布尔表达式X = A · (B + C)读懂它,并构建它的真值表
逻辑电路用导线连起来的门逐行追踪它,得到真值表
真值表每一行输入,以及每行对应的输出用它来化简表达式或设计电路

Explainer

讲解

How many rows, and in what order

多少行,按什么顺序

With n inputs there are 2n rows: 2 inputs give 4 rows, 3 inputs give 8. Fill the input columns by counting up in binary from all-zeros: the rightmost column alternates 0, 1 every row; the next alternates every two rows; the next every four. That order guarantees every combination appears exactly once.

有 n 个输入就有 2n 行:2 个输入 4 行,3 个输入 8 行。从全 0 开始按二进制递增来填输入列:最右一列每行在 0、1 之间交替;下一列每两行交替一次;再下一列每四行。这个顺序保证每种组合都恰好出现一次。

For anything with more than one gate, give each gate's output its own letter (P, Q) and fill a column for it before combining into the final output.

对于不止一个门的电路,给每个门的输出取一个字母(P、Q),先为它填一列,再组合成最终输出。

Worked example

例题

From a problem to a truth table

从问题到真值表

Problem: a greenhouse roof vent opens when the heater is on and either the humidity is high or the temperature is high. Inputs: H (heater), D (humidity high), T (temperature high). Output: X (vent opens).

问题:温室的屋顶通风口在加热器开着、并且湿度高或温度高时打开。输入:H(加热器)、D(湿度高)、T(温度高)。输出:X(通风口打开)。

Worked example

例题

Simplifying with a Karnaugh map

用卡诺图化简

A Karnaugh map (K-map) rearranges a truth table's output column into a grid so that groups of 1s become visible. Grouping them gives a shorter expression, which means a smaller circuit. Here is X = A’·B·C + A·B·C + A·B·C’.

卡诺图(K-map)把真值表的输出列重新排进一个网格,使一组组的 1 变得直观。把它们分组就得到更短的表达式,也就是更小的电路。这里是 X = A’·B·C + A·B·C + A·B·C’。

Grouping rules 分组规则

Groups hold 1, 2, 4, 8 … cells (a power of 2), form a rectangle or square (never a diagonal), are made as large as possible, may overlap, and the map wraps around its edges. For each group, keep the variables that stay the same across it and drop the ones that change.

每个组含 1、2、4、8 … 个单元(2 的幂),形成矩形或正方形(不能是对角线),尽可能做大,可以重叠,并且卡诺图的边是环绕相连的。对每个组,保留在组内保持不变的变量,去掉发生变化的变量。

Explainer

讲解

The same result by algebra

用代数得到同样的结果

A Karnaugh map is one route to the simplified expression; the Boolean algebra rules are the other. Starting from the same three terms:

卡诺图是通向化简表达式的一条路;布尔代数规则是另一条。从同样的三项出发:

StepWorkingRule used
StartX = A’·B·C + A·B·C + A·B·C’–
1= B·C·(A’ + A) + A·B·C’Factor out B·C
2= B·C·1 + A·B·C’ = B·C + A·B·C’A’ + A = 1 (complement)
3= B·(C + A·C’)Factor out B
4= B·(C + A)C + A·C’ = C + A (absorption)
ResultX = B·(A + C), which is A·B + B·CDistribution
步骤推导用到的规则
起始X = A’·B·C + A·B·C + A·B·C’–
1= B·C·(A’ + A) + A·B·C’提取公因子 B·C
2= B·C·1 + A·B·C’ = B·C + A·B·C’A’ + A = 1(互补律)
3= B·(C + A·C’)提取公因子 B
4= B·(C + A)C + A·C’ = C + A(吸收律)
结果X = B·(A + C),即 A·B + B·C分配律

Both routes end at the same place. The K-map is faster to do by hand and harder to get wrong; algebra is needed when there are more than four or five variables, where a K-map becomes unwieldy.

两条路都到达同一个地方。卡诺图手算更快、更不容易出错;当变量多于四五个、卡诺图变得笨重时,就需要代数。

Check your understanding

检验你的理解

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

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

Common mistake

常见错误

Recurring errors in truth tables and K-maps 真值表和卡诺图中反复出现的错误

RecurringLabelling a K-map's columns in plain binary order (00, 01, 10, 11) instead of Gray code (00, 01, 11, 10). Gray code changes only one bit between neighbours, which is exactly what lets adjacent 1s be grouped; plain binary order breaks the grouping and gives a wrong simplification. A second slip: leaving rows out of a truth table. With 3 inputs there must be 8 rows, always, even the ones where the output is 0.

反复出现把卡诺图的列按普通二进制顺序(00、01、10、11)标注,而不是格雷码(00、01、11、10)。格雷码在相邻两列之间只改变一个位,这正是让相邻的 1 能被分组的原因;普通二进制顺序会破坏分组,给出错误的化简。第二个错误:真值表漏行。3 个输入就必须有 8 行,永远如此,连输出为 0 的行也要写。

✕

Wrong: "I labelled the K-map columns 00, 01, 10, 11 like normal binary counting, then grouped the 1s in the first two columns."

错误: "我把卡诺图的列按普通二进制计数标成 00、01、10、11,然后把前两列的 1 分成一组。"

✓

Right: "K-map columns go 00, 01, 11, 10 (Gray code) so neighbouring columns differ in one variable only. Adjacent 1s can then be grouped, and the map wraps around, so the last column is also next to the first."

正确: "卡诺图的列按 00、01、11、10(格雷码)排列,使相邻列只在一个变量上不同。这样相邻的 1 才能分组,而且卡诺图边缘环绕相连,所以最后一列也和第一列相邻。"

Revision questions

复习题

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

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 2 marks 第 1 题 · 2 分

[2]Construct a truth table for X = A AND NOT B.

[2]为 X = A AND NOT B 构建真值表。

Question 2 · 3 marks 第 2 题 · 3 分

[3]Build the truth table for X = (A OR C) AND (NOT B), including one intermediate column for the OR gate.

[3]为表达式 X = (A OR C) AND (NOT B) 构建真值表,使用一个中间列。

Question 3 · 3 marks 第 3 题 · 3 分

[3]A pump should run only when the tank is not full and either the timer is active or the manual switch is on. Draw up the full truth table for the system.

[3]一个水泵只有在水箱未满、并且定时器已启动或手动开关打开时才运行。为这个系统构建真值表。

Question 4 · 4 marks 第 4 题 · 4 分

[4]Draw the Karnaugh map for X = A’·B·C’ + A’·B·C + A·B·C and write the simplified expression.

[4]为 X = A’·B·C’ + A’·B·C + A·B·C 画卡诺图,并写出化简后的表达式。

Question 5 · 3 marks 第 5 题 · 3 分

[3]Explain why a Karnaugh map's column headings use Gray code rather than plain binary counting.

[3]解释为什么卡诺图的列标题使用格雷码而不是普通的二进制计数。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide, the specimen papers and the Hodder and Oxford IB CS 2027 texts for A1.2.4 · not yet wired to live routes