← 学习库 Discrete Mathematics (Levin) · 中英对照 目录

1.1 Additive and Multiplicative Principles 加法与乘法原理

本页译自 LibreTexts · Discrete Mathematics (Levin) 第 1.1 章。公式经 MathJax 渲染,自定义宏已注入。

Investigate! 探究!

  1. A restaurant offers 8 appetizers and 14 entrées. How many choices do you have if:
    1. you will eat one dish, either an appetizer or an entrée?
    2. you are extra hungry and want to eat both an appetizer and an entrée?
  2. Think about the methods you used to solve question 1. Write down the rules for these methods.
  3. Do your rules work? A standard deck of playing cards has 26 red cards and 12 face cards.
    1. How many ways can you select a card which is either red or a face card?
    2. How many ways can you select a card which is both red and a face card?
    3. How many ways can you select two cards so that the first one is red and the second one is a face card?
  1. 一家餐厅提供 8 种开胃菜和 14 种主菜。你有多少种选择,如果:
    1. 你只吃一道菜,要么是开胃菜,要么是主菜?
    2. 你格外饥饿,想同时吃一道开胃菜和一道主菜?
  2. 想一想你解第 1 题所用的方法,把这两种方法的规则写下来。
  3. 你的规则站得住脚吗?一副标准扑克牌有 26 张红色牌和 12 张人头牌。
    1. 有多少种选法可以选出一张「红色牌或人头牌」?
    2. 有多少种选法可以选出一张「既是红色牌又是人头牌」的牌?
    3. 有多少种选法可以依次抽出两张牌,使得第一张是红色牌、第二张是人头牌?

Consider this rather simple counting problem: at Red Dogs and Donuts, there are 14 varieties of donuts, and 16 types of hot dogs. If you want either a donut or a dog, how many options do you have? This isn't too hard, just add 14 and 16. Will that always work? What is important here?

考虑一个相当简单的计数问题:在「红狗与甜甜圈」店里有 14 种甜甜圈和 16 种热狗。如果你想要一份甜甜圈或一份热狗,共有多少种选择?这并不难,只要把 14 和 16 相加即可。但那样做永远成立吗?这里的关键又是什么?

Additive Principle 加法原理

The additive principle states that if event $A$ can occur in $m$ ways, and event $B$ can occur in $n$ disjoint ways, then the event “$A$ or $B$” can occur in $m + n$ ways.

加法原理指出:若事件 $A$ 有 $m$ 种发生方式,事件 $B$ 有 $n$ 种互不相交的发生方式,则事件「$A$ 或 $B$」共有 $m + n$ 种发生方式。

It is important that the events be disjoint: i.e., that there is no way for $A$ and $B$ to both happen at the same time. For example, a standard deck of 52 cards contains $26$ red cards and $12$ face cards. However, the number of ways to select a card which is either red or a face card is not $26 + 12 = 38\text{.}$ This is because there are 6 cards which are both red and face cards.

关键在于这两个事件必须互不相交,也就是说,$A$ 与 $B$ 不可能同时发生。例如,一副 52 张的标准扑克牌中有 $26$ 张红色牌和 $12$ 张人头牌。然而,「选出一张红色牌或人头牌」的选法数并不是 $26 + 12 = 38\text{。}$ 原因在于有 6 张牌既是红色牌又是人头牌。

Example 1

示例 1

How many two letter “words” start with either A or B? (A word is just a string of letters; it doesn't have to be English, or even pronounceable.)

有多少个由两个字母组成的「单词」以 A 或 B 开头?(这里的单词只是字母串,不必是英语单词,甚至不必能发音。)

Solution

解答

First, how many two letter words start with A? We just need to select the second letter, which can be accomplished in 26 ways. So there are 26 words starting with A. There are also 26 words that start with B. To select a word which starts with either A or B, we can pick the word from the first 26 or the second 26, for a total of 52 words.

首先,有多少个以 A 开头的两字母单词?只需选定第二个字母,共有 26 种选法,所以以 A 开头的单词有 26 个。以 B 开头的单词同样有 26 个。要选出以 A 或 B 开头的单词,可以从前 26 个或后 26 个中挑选,共计 52 个单词。

The additive principle also works with more than two events. Say, in addition to your 14 choices for donuts and 16 for dogs, you would also consider eating one of 15 waffles? How many choices do you have now? You would have $14 + 16 + 15 = 45$ options.

加法原理也适用于两个以上的事件。比方说,除了 14 种甜甜圈和 16 种热狗,你还考虑吃 15 种华夫饼中的一种?现在你有多少种选法?你将有 $14 + 16 + 15 = 45$ 种选择。

Example 2

示例 2

How many two letter words start with one of the 5 vowels?

有多少个两字母单词以 5 个元音字母中的某一个开头?

Solution

解答

There are 26 two letter words starting with A, another 26 starting with E, and so on. We will have 5 groups of 26. So we add 26 to itself 5 times. Of course it would be easier to just multiply $5\cdot 26\text{.}$ We are really using the additive principle again, just using multiplication as a shortcut.

以 A 开头的两字母单词有 26 个,以 E 开头的有另外 26 个,依此类推。我们将得到 5 组、每组 26 个。于是把 26 连加 5 次。当然,直接乘 $5\cdot 26$ 更简便。这其实仍是加法原理,只不过用乘法作为简写。

Example 3

示例 3

Suppose you are going for some fro-yo. You can pick one of 6 yogurt choices, and one of 4 toppings. How many choices do you have?

假设你要来点冻酸奶。你可以从 6 种酸奶中选一种,再从 4 种配料中选一种。你共有多少种选择?

Solution

解答

Break your choices up into disjoint events: $A$ are the choices with the first topping, $B$ the choices featuring the second topping, and so on. There are four events; each can occur in 6 ways (one for each yogurt flavor). The events are disjoint, so the total number of choices is $6 + 6 + 6 + 6 = 24\text{.}$

把你的选择拆成互不相交的事件:事件 $A$ 是选第一种配料的各项选择,事件 $B$ 是选第二种配料的各项选择,依此类推。共有四个事件,每个事件都有 6 种发生方式(对应每种酸奶口味)。这些事件互不相交,因此总选择数为 $6 + 6 + 6 + 6 = 24\text{。}$

Note that in both of the previous examples, when using the additive principle on a bunch of events all the same size, it is quicker to multiply. This really is the same, and not just because $6 + 6 + 6 + 6 = 4\cdot 6\text{.}$ We can first select the topping in 4 ways (that is, we first select which of the disjoint events we will take). For each of those first 4 choices, we now have 6 choices of yogurt. We have:

注意,在上面两个例子中,当用加法原理处理一组大小相同的事件时,直接相乘更快。这二者确实是一回事,并不仅仅因为 $6 + 6 + 6 + 6 = 4\cdot 6\text{。}$ 我们可以先以 4 种方式选定配料(即先选定要取哪一个互不相交的事件)。对于前 4 种选择中的每一种,我们又有 6 种酸奶口味可选。于是:

Multiplicative Principle 乘法原理

The multiplicative principle states that if event $A$ can occur in $m$ ways, and each possibility for $A$ allows for exactly $n$ ways for event $B\text{,}$ then the event “$A$ and $B$” can occur in $m \cdot n$ ways.

乘法原理指出:若事件 $A$ 有 $m$ 种发生方式,且 $A$ 的每一种可能都恰好对应事件 $B$ 的 $n$ 种发生方式,则事件「$A$ 且 $B$」共有 $m \cdot n$ 种发生方式。

The multiplicative principle generalizes to more than two events as well.

乘法原理同样可以推广到两个以上的事件。

Example 4

示例 4

How many license plates can you make out of three letters followed by three numerical digits?

由三个字母后接三个数字能组成多少个车牌?

Solution

解答

Here we have six events: the first letter, the second letter, the third letter, the first digit, the second digit, and the third digit. The first three events can each happen in 26 ways; the last three can each happen in 10 ways. So the total number of license plates will be $26\cdot 26\cdot 26 \cdot 10 \cdot 10 \cdot 10\text{,}$ using the multiplicative principle.

这里有六个事件:第一个字母、第二个字母、第三个字母、第一位数字、第二位数字、第三位数字。前三个事件各有 26 种发生方式,后三个事件各有 10 种发生方式。根据乘法原理,车牌总数为 $26\cdot 26\cdot 26 \cdot 10 \cdot 10 \cdot 10\text{。}$

Does this make sense? Think about how we would pick a license plate. How many choices we would have? First, we need to pick the first letter. There are 26 choices. Now for each of those, there are 26 choices for the second letter: 26 second letters with first letter A, 26 second letters with first letter B, and so on. We add 26 to itself 26 times. Or quicker: there are $26 \cdot 26$ choices for the first two letters.

这合理吗?想想我们是如何选定一个车牌的。我们共有多少种选择?首先,要选定第一个字母,有 26 种选择。对其中每一种,第二个字母都有 26 种选择:第一个字母是 A 时有 26 个第二个字母,是 B 时又有 26 个,依此类推。也就是把 26 连加 26 次。更简便地说:前两个字母共有 $26 \cdot 26$ 种选择。

Now for each choice of the first two letters, we have 26 choices for the third letter. That is, 26 third letters for the first two letters AA, 26 choices for the third letter after starting AB, and so on. There are $26 \cdot 26$ of these $26$ third letter choices, for a total of $(26\cdot26)\cdot 26$ choices for the first three letters. And for each of these $26\cdot26\cdot26$ choices of letters, we have a bunch of choices for the remaining digits.

对于前两个字母的每一种选择,第三个字母都有 26 种选择。也就是说,前两个字母是 AA 时有 26 个第三个字母,以 AB 开头时又有 26 个第三个字母,依此类推。这样的第三个字母共有 $26 \cdot 26$ 组(每组 26 个),所以前三个字母共有 $(26\cdot26)\cdot 26$ 种选择。而在这 $26\cdot26\cdot26$ 种字母选择的每一种之下,剩余的数字都还有一大堆选择。

In fact, there are going to be exactly 1000 choices for the numbers. We can see this because there are 1000 three-digit numbers (000 through 999). This is 10 choices for the first digit, 10 for the second, and 10 for the third. The multiplicative principle says we multiply: $10\cdot 10 \cdot 10 = 1000\text{.}$

事实上,数字部分恰好有 1000 种选择。这是因为三位数字共有 1000 个(从 000 到 999)。第一位数字有 10 种选择,第二位有 10 种,第三位也有 10 种。乘法原理告诉我们把它们相乘:$10\cdot 10 \cdot 10 = 1000\text{。}$

All together, there were $26^3$ choices for the three letters, and $10^3$ choices for the numbers, so we have a total of $26^3 \cdot 10^3$ choices of license plates.

综合起来,三个字母有 $26^3$ 种选择,数字有 $10^3$ 种选择,因此车牌总数为 $26^3 \cdot 10^3$。

Careful: “and” doesn't mean “times.” For example, how many playing cards are both red and a face card? Not $26 \cdot 12\text{.}$ The answer is 6, and we needed to know something about cards to answer that question.

当心:「且(and)」并不等于「相乘(times)」。例如,有多少张扑克牌既是红色牌又是人头牌?并不是 $26 \cdot 12\text{。}$ 答案是 6,而要得出这个答案,我们必须对扑克牌有所了解。

Another caution: how many ways can you select two cards, so that the first one is a red card and the second one is a face card? This looks more like the multiplicative principle (you are counting two separate events) but the answer is not $26 \cdot 12$ here either. The problem is that while there are 26 ways for the first card to be selected, it is not the case that for each of those there are 12 ways to select the second card. If the first card was both red and a face card, then there would be only 11 choices for the second card. [1] To solve this problem, you could break it into two cases. First, count how many ways there are to select the two cards when the first card is a red non-face card. Second, count how many ways when the first card is a red face card. Doing so makes the events in each separate case independent, so the multiplicative principle can be applied.

另一点要当心:有多少种选法可以依次抽出两张牌,使第一张是红色牌、第二张是人头牌?这看上去更像乘法原理(你在数两个独立的事件),但答案在这里同样不是 $26 \cdot 12$。问题在于,虽然第一张牌有 26 种选法,但并非其中每一种都对应第二张牌的 12 种选法。如果第一张牌既是红色牌又是人头牌,那么第二张牌就只剩 11 种选择。[1] 要解决这个问题,可以把它拆成两种情形:第一种,第一张牌是「红色非人头牌」时,选出这两张牌有多少种选法;第二种,第一张牌是「红色人头牌」时,有多少种选法。这样处理之后,每种情形内部的事件彼此独立,乘法原理便可以应用。

Counting functions 计数函数

How many functions $f:\{1,2,3,4,5\} \to \{a,b,c,d\}$ are there?

有多少个函数 $f:\{1,2,3,4,5\} \to \{a,b,c,d\}$?

Solution

解答

Remember that a function sends each element of the domain to exactly one element of the codomain. To determine a function, we just need to specify the image of each element in the domain. Where can we send 1? There are 4 choices. Where can we send 2? Again, 4 choices. What we have here is 5 “events” (picking the image of an element in the domain) each of which can happen in 4 ways (the choices for that image). Thus there are $4 \cdot 4 \cdot 4 \cdot 4 \cdot 4 = 4^5$ functions.

记住,函数把定义域中的每个元素都恰好映到上域中的一个元素。要确定一个函数,只需指定定义域中每个元素的像。元素 1 可以映到哪里?有 4 种选择。元素 2 可以映到哪里?同样有 4 种。这里我们有 5 个「事件」(为每个定义域元素选定像),每个事件都有 4 种发生方式(该像的候选数)。因此共有 $4 \cdot 4 \cdot 4 \cdot 4 \cdot 4 = 4^5$ 个函数。

This is more than just an example of how we can use the multiplicative principle in a particular counting question. What we have here is a general interpretation of certain applications of the multiplicative principle using rigorously defined mathematical objects: functions. Whenever we have a counting question that asks for the the number of outcomes of a repeated event, we can interpret that as asking for the number of functions from $\{1,2,\ldots, n\}$ (where $n$ is the number of times the event is repeated) to $\{1,2,\ldots,k\}$ (where $k$ is the number of ways that event can occur).

这不仅仅是一个「如何在具体计数问题中使用乘法原理」的例子。我们在此得到的是乘法原理某些应用的一种通用解释,而这借助于严格定义的数学对象——函数。每当我们遇到一个计数问题,要求某个重复发生的事件的所有可能结果数,我们都可以把它理解为:求从 $\{1,2,\ldots, n\}$(其中 $n$ 是事件重复的次数)到 $\{1,2,\ldots,k\}$(其中 $k$ 是该事件每次发生的方式数)的函数个数。

Counting With Sets 用集合计数

Do you believe the additive and multiplicative principles? How would you convince someone they are correct? This is surprisingly difficult. They seem so simple, so obvious. But why do they work?

你相信加法原理和乘法原理吗?你又如何说服别人它们是正确的?这出乎意料地困难。它们看似如此简单、如此显然。可它们为什么成立呢?

To make things clearer, and more mathematically rigorous, we will use sets. Do not skip this section! It might seem like we are just trying to give a proof of these principles, but we are doing a lot more. If we understand the additive and multiplicative principles rigorously, we will be better at applying them, and knowing when and when not to apply them at all.

为了让事情更清晰、也更具有数学上的严谨性,我们将使用集合。不要跳过这一节!它看上去似乎只是想给这些原理一个证明,但其实我们做的远不止于此。如果我们严谨地理解了加法原理与乘法原理,就能更好地运用它们,并且清楚何时该用、何时根本不该用。

We will look at the additive and multiplicative principles in a slightly different way. Instead of thinking about event $A$ and event $B\text{,}$ we want to think of a set $A$ and a set $B\text{.}$ The sets will contain all the different ways the event can happen. (It will be helpful to be able to switch back and forth between these two models when checking that we have counted correctly.) Here's what we mean:

我们将以一种略有不同的方式来看待加法原理和乘法原理。与其考虑事件 $A$ 和事件 $B\text{,}$我们不如考虑集合 $A$ 和集合 $B\text{。}$ 这些集合将包含该事件所有可能的发生方式。(在核对计数是否正确时,能够在这两种模型之间来回切换会很有帮助。)下面用一个例子说明:

Example 6

示例 6

Suppose you own 9 shirts and 5 pairs of pants.

假设你有 9 件衬衫和 5 条裤子。
  1. How many outfits can you make?
  2. If today is half-naked-day, and you will wear only a shirt or only a pair of pants, how many choices do you have?
  1. 你能搭配出多少套衣服?
  2. 如果今天是「半裸日」,你只穿一件衬衫或只穿一条裤子,你有多少种选择?

Answer

解答

By now you should agree that the answer to the first question is $9 \cdot 5 = 45$ and the answer to the second question is $9 + 5 = 14\text{.}$ These are the multiplicative and additive principles. There are two events: picking a shirt and picking a pair of pants. The first event can happen in 9 ways and the second event can happen in 5 ways. To get both a shirt and a pair of pants, you multiply. To get just one article of clothing, you add.

至此你应当认同:第一问的答案是 $9 \cdot 5 = 45$,第二问的答案是 $9 + 5 = 14\text{。}$ 这正是乘法原理与加法原理。这里有两个事件:选一件衬衫、选一条裤子。第一个事件有 9 种发生方式,第二个事件有 5 种发生方式。要同时得到一件衬衫和一条裤子,就把两者相乘;只要一件衣物,就把两者相加。

Now look at this using sets. There are two sets, call them $S$ and $P\text{.}$ The set $S$ contains all 9 shirts so $|S| = 9$ while $|P| = 5\text{,}$ since there are 5 elements in the set $P$ (namely your 5 pairs of pants). What are we asking in terms of these sets? Well in question 2, we really want $|S \cup P|\text{,}$ the number of elements in the union of shirts and pants. This is just $|S| + |P|$ (since there is no overlap; $|S \cap P| = 0$). Question 1 is slightly more complicated. Your first guess might be to find $|S \cap P|\text{,}$ but this is not right (there is nothing in the intersection). We are not asking for how many clothing items are both a shirt and a pair of pants. Instead, we want one of each. We could think of this as asking how many pairs $(x,y)$ there are, where $x$ is a shirt and $y$ is a pair of pants. As we will soon verify, this number is $|S| \cdot |P|\text{.}$

现在用集合的视角来看。有两个集合,记为 $S$ 和 $P\text{。}$ 集合 $S$ 包含全部 9 件衬衫,所以 $|S| = 9$;而 $|P| = 5\text{,}$因为集合 $P$ 中有 5 个元素(即你的 5 条裤子)。用这些集合来表述,我们到底在问什么?在第二问中,我们真正想要的是 $|S \cup P|\text{,}$即衬衫与裤子并集中的元素个数。它就等于 $|S| + |P|$(因为二者没有重叠,$|S \cap P| = 0$)。第一问稍微复杂一些。你第一个想到的可能是求 $|S \cap P|\text{,}$但这不对(交集里空无一物)。我们并不是在问有多少件衣物「既是衬衫又是裤子」。相反,我们要的是各取一件。这不妨理解为:有多少个有序对 $(x,y)$,其中 $x$ 是一件衬衫、$y$ 是一条裤子。我们很快就会验证,这个数目等于 $|S| \cdot |P|\text{。}$

From this example we can see right away how to rephrase our additive principle in terms of sets:

从这个例子立刻可以看出,如何用集合的语言重新表述加法原理:

Additive Principle (with sets) 加法原理(集合表述)

Given two sets $A$ and $B\text{,}$ if $A \cap B = \emptyset$ (that is, if there is no element in common to both $A$ and $B$), then

给定两个集合 $A$ 与 $B\text{,}$若 $A \cap B = \emptyset$(即 $A$ 与 $B$ 没有公共元素),则

$\begin{equation*} |A \cup B| = |A| + |B|. \end{equation*}$

This hardly needs a proof. To find $A \cup B\text{,}$ you take everything in $A$ and throw in everything in $B\text{.}$ Since there is no element in both sets already, you will have $|A|$ things and add $|B|$ new things to it. This is what adding does! Of course, we can easily extend this to any number of disjoint sets.

这几乎无需证明。要求 $A \cup B\text{,}$只需取 $A$ 中的一切,再并入 $B$ 中的一切。既然两个集合本来没有公共元素,你已有 $|A|$ 个东西,再添上 $|B|$ 个新东西即可。这正是「相加」的含义!当然,我们也可以轻易地把这推广到任意多个互不相交的集合。

From the example above, we see that in order to investigate the multiplicative principle carefully, we need to consider ordered pairs. We should define this carefully:

从上面的例子可见,要严谨地考察乘法原理,我们必须考虑有序对。下面给出严格定义:

Cartesian Product 笛卡尔积

Given sets $A$ and $B\text{,}$ we can form the set $A \times B = \{(x,y) \mid x \in A \wedge y \in B\}$ to be the set of all ordered pairs $(x,y)$ where $x$ is an element of $A$ and $y$ is an element of $B\text{.}$ We call $A \times B$ the Cartesian product of $A$ and $B\text{.}$

给定集合 $A$ 与 $B\text{,}$我们可以构造集合 $A \times B = \{(x,y) \mid x \in A \wedge y \in B\}$,它由所有满足「$x$ 是 $A$ 的元素且 $y$ 是 $B$ 的元素」的有序对 $(x,y)$ 组成。我们称 $A \times B$ 为 $A$ 与 $B$ 的笛卡尔积(Cartesian product)

Example 7

示例 7

Let $A = \{1,2\}$ and $B=\{3,4,5\}\text{.}$ Find $A \times B\text{.}$

设 $A = \{1,2\}$,$B=\{3,4,5\}\text{。}$ 求 $A \times B\text{。}$

Answer

解答

We want to find ordered pairs $(a,b)$ where $a$ can be either $1$ or $2$ and $b$ can be either 3, 4, or 5. $A \times B$ is the set of all of these pairs:

我们要找所有有序对 $(a,b)$,其中 $a$ 取 $1$ 或 $2$,$b$ 取 3、4 或 5。$A \times B$ 就是所有这些有序对构成的集合:

$\begin{equation*} A \times B = \{(1,3), (1,4), (1,5), (2,3), (2,4), (2,5)\} \end{equation*}$

The question is, what is $|A \times B|\text{?}$ To figure this out, write out $A \times B\text{.}$ Let $A = \{a_1,a_2, a_3, \ldots, a_m\}$ and $B = \{b_1,b_2, b_3, \ldots, b_n\}$ (so $|A| = m$ and $|B| = n$). The set $A \times B$ contains all pairs with the first half of the pair being some $a_i \in A$ and the second being one of the $b_j \in B\text{.}$ In other words:

问题是,$|A \times B|$ 等于多少?要弄清这一点,可以把 $A \times B$ 写出来。设 $A = \{a_1,a_2, a_3, \ldots, a_m\}$,$B = \{b_1,b_2, b_3, \ldots, b_n\}$(于是 $|A| = m$,$|B| = n$)。集合 $A \times B$ 包含所有这样的有序对:其前半部分是某个 $a_i \in A$,后半部分是某个 $b_j \in B\text{。}$ 换言之:

$\begin{align*} A \times B = & (a_1, b_1), (a_1, b_2), (a_1, b_3), \ldots (a_1, b_n),\\ & (a_2, b_1), (a_2, b_2), (a_2, b_3), \ldots, (a_2, b_n),\\ & (a_3, b_1), (a_3, b_2), (a_3, b_3), \ldots, (a_3, b_n),\\ & \vdots\\ & (a_m, b_1), (a_m, b_2), (a_m, b_3), \ldots, (a_m, b_n). \end{align*}$

Notice what we have done here: we made $m$ rows of $n$ pairs, for a total of $m \cdot n$ pairs.

注意我们在这里做了什么:我们排出了 $m$ 行、每行 $n$ 个有序对,总共 $m \cdot n$ 个有序对。

Each row above is really $\{a_i\} \times B$ for some $a_i \in A\text{.}$ That is, we fixed the $A$-element. Broken up this way, we have

上面每一行其实都是某个 $a_i \in A$ 对应的 $\{a_i\} \times B\text{。}$ 也就是说,我们固定了 $A$ 中的元素。这样拆分后,可得

$\begin{equation*} A \times B = (\{a_1\} \times B) \cup (\{a_2\} \times B) \cup (\{a_3\}\times B) \cup \cdots \cup (\{a_m\} \times B). \end{equation*}$

So $A \times B$ is really the union of $m$ disjoint sets. Each of those sets has $n$ elements in them. The total (using the additive principle) is $n + n + n + \cdots + n = m \cdot n\text{.}$

所以 $A \times B$ 其实是 $m$ 个互不相交集合的并集。其中每个集合都含有 $n$ 个元素。总数(运用加法原理)为 $n + n + n + \cdots + n = m \cdot n\text{。}$

To summarize:

小结如下:

Multiplicative Principle (with sets) 乘法原理(集合表述)

Given two sets $A$ and $B\text{,}$ we have $|A \times B| = |A| \cdot |B|\text{.}$

给定两个集合 $A$ 与 $B\text{,}$有 $|A \times B| = |A| \cdot |B|\text{。}$

Again, we can easily extend this to any number of sets.

同样,我们也可以轻易地把这推广到任意多个集合。

Principle of Inclusion/Exclusion 容斥原理

Investigate!

探究!

A recent buzz marketing campaign for Village Inn surveyed patrons on their pie preferences. People were asked whether they enjoyed (A) Apple, (B) Blueberry or (C) Cherry pie (respondents answered yes or no to each type of pie, and could say yes to more than one type). The following table shows the results of the survey.

最近,「乡村客栈(Village Inn)」的一场口碑营销活动调查了顾客对派(pie)的偏好。受访者被问及是否喜欢(A)苹果派、(B)蓝莓派或(C)樱桃派(对每种派回答「喜欢」或「不喜欢」,且可以不止一种说「喜欢」)。下表展示了调查结果。
Pies enjoyed:ABCABACBCABC
Number of people:20132691575
(上表:一项关于「喜爱的派」的调查。列 A、B、C 及其组合 AB、AC、BC、ABC 表示受访者喜爱的派之组合;行「Number of people」为对应组合的人数,例如喜爱派 A 的有 20 人,三者都喜爱的(ABC)有 5 人。)
(上表:一项关于「喜爱的派」的调查。列 A、B、C 及其组合 AB、AC、BC、ABC 表示受访者喜爱的派之组合;行「Number of people」为对应组合的人数,例如喜爱派 A 的有 20 人,三者都喜爱的(ABC)有 5 人。)

How many of those asked enjoy at least one of the kinds of pie? Also, explain why the answer is not 95.

在被调查者中,有多少人至少喜欢其中一种派?另外,请解释为什么答案不是 95。

While we are thinking about sets, consider what happens to the additive principle when the sets are NOT disjoint. Suppose we want to find $|A \cup B|$ and know that $|A| = 10$ and $|B| = 8\text{.}$ This is not enough information though. We do not know how many of the 8 elements in $B$ are also elements of $A\text{.}$ However, if we also know that $|A \cap B| = 6\text{,}$ then we can say exactly how many elements are in $A\text{,}$ and, of those, how many are in $B$ and how many are not (6 of the 10 elements are in $B\text{,}$ so 4 are in $A$ but not in $B$). We could fill in a Venn diagram as follows:

既然我们在讨论集合,不妨看看:当集合不相交时,加法原理会发生什么。假设我们想求 $|A \cup B|$,并且已知 $|A| = 10$、$|B| = 8\text{。}$ 但这些信息还不够。我们并不知道 $B$ 中的 8 个元素里有多少个同时也是 $A$ 的元素。不过,如果我们还知道 $|A \cap B| = 6\text{,}$就能确切说出 $A$ 中有多少元素、其中又有多少属于 $B$、多少不属于($A$ 的 10 个元素中有 6 个在 $B$ 中,于是有 4 个在 $A$ 中但不在 $B$ 中)。我们可以据此画出一个维恩图:

This says there are 6 elements in $A \cap B\text{,}$ 4 elements in $A \setminus B$ and 2 elements in $B \setminus A\text{.}$ Now these three sets are disjoint, so we can use the additive principle to find the number of elements in $A \cup B\text{.}$ It is $6 + 4 + 2 = 12\text{.}$

这表示:$A \cap B$ 中有 6 个元素,$A \setminus B$ 中有 4 个,$B \setminus A$ 中有 2 个。现在这三个集合彼此互不相交,因此可用加法原理求出 $A \cup B$ 中的元素个数,即 $6 + 4 + 2 = 12\text{。}$

This will always work, but drawing a Venn diagram is more than we need to do. In fact, it would be nice to relate this problem to the case where $A$ and $B$ are disjoint. Is there one rule we can make that works in either case?

这方法永远有效,但画维恩图超出了我们的需要。事实上,若能把这个问题与 $A$、$B$ 不相交的情形联系起来就更好了。能不能归纳出一条对两种情形都适用的规则?

Here is another way to get the answer to the problem above. Start by just adding $|A| + |B|\text{.}$ This is $10 + 8 = 18\text{,}$ which would be the answer if $|A \cap B| = 0\text{.}$ We see that we are off by exactly 6, which just so happens to be $|A \cap B|\text{.}$ So perhaps we guess,

下面换一种方式来得到上面的答案。先直接把 $|A| + |B|$ 相加,得到 $10 + 8 = 18\text{,}$若 $|A \cap B| = 0$ 这就是答案。我们发现结果恰好多了 6,而这个数正好就是 $|A \cap B|\text{。}$ 于是我们不妨猜想:

$\begin{equation*} |A \cup B| = |A| + |B| - |A \cap B|. \end{equation*}$

This works for this one example. Will it always work? Think about what we are doing here. We want to know how many things are either in $A$ or $B$ (or both). We can throw in everything in $A\text{,}$ and everything in $B\text{.}$ This would give $|A| + |B|$ many elements. But of course when you actually take the union, you do not repeat elements that are in both. So far we have counted every element in $A \cap B$ exactly twice: once when we put in the elements from $A$ and once when we included the elements from $B\text{.}$ We correct by subtracting out the number of elements we have counted twice. So we added them in twice, subtracted once, leaving them counted only one time.

这在一个例子上成立。它是否永远成立?想想我们在这里做了什么。我们想知道有多少东西在 $A$ 中或在 $B$ 中(或两者兼有)。我们可以把 $A$ 中的一切和 $B$ 中的一切都放进来,这样会得到 $|A| + |B|$ 个元素。但实际取并集时,当然不会重复计算同时属于两者的元素。到目前为止,我们把 $A \cap B$ 中的每个元素恰好数了两次:一次在放入 $A$ 的元素时,一次在放入 $B$ 的元素时。我们通过减去「被多数了一次」的元素个数来修正。于是:加进来两次,减去一次,最终只被数了一次。

In other words, we have:

换言之,我们得到:

Cardinality of a union (2 sets) (两个集合)并集的基数

For any finite sets $A$ and $B\text{,}$

对任意有限集合 $A$ 与 $B\text{,}$

$\begin{equation*} |A \cup B| = |A| + |B| - |A \cap B|. \end{equation*}$

We can do something similar with three sets.

对三个集合也可以做类似的处理。

Example 8

示例 8

An examination in three subjects, Algebra, Biology, and Chemistry, was taken by 41 students. The following table shows how many students failed in each single subject and in their various combinations:

41 名学生参加了一门涵盖代数、生物、化学三科的考试。下表显示了在每一单科以及各组合中不及格的学生人数:
Subject:ABCABACBCABC
Failed:12582631
(上表:各科目(A、B、C 及其组合)的不及格人数。行「Failed」为对应组合下不及格的人数,例如仅科目 A 不及格的有 12 人,三科均不及格(ABC)的有 1 人。)
(上表:各科目(A、B、C 及其组合)的不及格人数。行「Failed」为对应组合下不及格的人数,例如仅科目 A 不及格的有 12 人,三科均不及格(ABC)的有 1 人。)

How many students failed at least one subject?

有多少名学生至少有一科不及格?

Solution

解答

The answer is not 37, even though the sum of the numbers above is 37. For example, while 12 students failed Algebra, 2 of those students also failed Biology, 6 also failed Chemistry, and 1 of those failed all three subjects. In fact, that 1 student who failed all three subjects is counted a total of 7 times in the total 37. To clarify things, let us think of the students who failed Algebra as the elements of the set $A\text{,}$ and similarly for sets $B$ and $C\text{.}$ The one student who failed all three subjects is the lone element of the set $A \cap B \cap C\text{.}$ Thus, in Venn diagrams:

答案并不是 37,尽管上面这些数字之和正是 37。例如,虽然有 12 名学生代数不及格,但其中 2 名也生物不及格,6 名也化学不及格,还有 1 名三科全部不及格。事实上,那名三科全不及格的学生在总数 37 中被数了足足 7 次。为理清头绪,不妨把代数不及格的学生看作集合 $A$ 的元素,$B$、$C$ 同理。那名三科全不及格的学生,正是集合 $A \cap B \cap C$ 中唯一的元素。于是,在维恩图中:

Now let's fill in the other intersections. We know $A\cap B$ contains 2 elements, but 1 element has already been counted. So we should put a 1 in the region where $A$ and $B$ intersect (but $C$ does not). Similarly, we calculate the cardinality of $(A\cap C) \setminus B\text{,}$ and $(B \cap C) \setminus A\text{:}$

现在来填充其余的交叉区域。已知 $A\cap B$ 含 2 个元素,但其中 1 个已被计入,所以应在 $A$ 与 $B$ 相交(但不与 $C$ 相交)的区域填入 1。同理,我们计算 $(A\cap C) \setminus B$ 与 $(B \cap C) \setminus A$ 的基数:

Next, we determine the numbers which should go in the remaining regions, including outside of all three circles. This last number is the number of students who did not fail any subject:

接着,确定剩余各个区域中应填入的数字,包括三个圆之外的区域。最后一个数字是没有不及格任何科目的学生人数:

We found 5 goes in the “$A$ only” region because the entire circle for $A$ needed to have a total of 12, and 7 were already accounted for. Similarly, we calculate the “$B$ only” region to contain only 1 student and the “$C$ only” region to contain no students.

我们发现,「仅 $A$」区域应填入 5,因为整个 $A$ 圆的总数须为 12,而其中 7 个已经算过。同理,算得「仅 $B$」区域只包含 1 名学生,「仅 $C$」区域则不含任何学生。

Thus the number of students who failed at least one class is 15 (the sum of the numbers in each of the eight disjoint regions). The number of students who passed all three classes is 26: the total number of students, 41, less the 15 who failed at least one class.

因此,至少有一科不及格的学生人数为 15(即八个互不相交区域中数字之和)。三科全部及格的学生人数为 26:学生总数 41 减去至少一科不及格的 15 人。

Note that we can also answer other questions. For example, now many students failed just Chemistry? None. How many passed Algebra but failed both Biology and Chemistry? This corresponds to the region inside both $B$ and $C$ but outside of $A\text{,}$ containing 2 students.

注意,我们还可以回答其他问题。例如,有多少名学生只化学不及格?零人。有多少名代数及格、但生物与化学都不及格?这对应 $B$ 与 $C$ 内部、却在 $A$ 之外的区域,包含 2 名学生。

Could we have solved the problem above in an algebraic way? While the additive principle generalizes to any number of sets, when we add a third set here, we must be careful. With two sets, we needed to know the cardinalities of $A\text{,}$ $B\text{,}$ and $A \cap B$ in order to find the cardinality of $A \cup B\text{.}$ With three sets we need more information. There are more ways the sets can combine. Not surprisingly then, the formula for cardinality of the union of three non-disjoint sets is more complicated:

我们能否用代数方法解出上面的问题?虽然加法原理可以推广到任意多个集合,但当我们在这里加入第三个集合时,必须格外小心。对两个集合,要知道 $A \cup B$ 的基数,只需知道 $A\text{、}$$B$ 以及 $A \cap B$ 的基数。对三个集合,我们需要更多信息,因为集合的组合方式更多了。于是毫不意外,三个不相交集合之并集的基数公式要复杂得多:

Cardinality of a union (3 sets) (三个集合)并集的基数

For any finite sets $A\text{,}$ $B\text{,}$ and $C\text{,}$

对任意有限集合 $A\text{、}$$B$ 与 $C\text{,}$

$\begin{equation*} |A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C| \end{equation*}$

To determine how many elements are in at least one of $A\text{,}$ $B\text{,}$ or $C$ we add up all the elements in each of those sets. However, when we do that, any element in both $A$ and $B$ is counted twice. Also, each element in both $A$ and $C$ is counted twice, as are elements in $B$ and $C\text{,}$ so we take each of those out of our sum once. But now what about the elements which are in $A \cap B \cap C$ (in all three sets)? We added them in three times, but also removed them three times. They have not yet been counted. Thus we add those elements back in at the end.

要确定 $A\text{、}$$B$ 或 $C$ 中至少有一个含有的元素个数,我们把这三个集合各自的元素全部相加。然而,这样做时,任何同时在 $A$ 与 $B$ 中的元素会被数两次;$A$ 与 $C$ 共有的、以及 $B$ 与 $C$ 共有的元素也都被数了两次,所以我们要把这些都从总和中各自减去一次。但那些在 $A \cap B \cap C$ 中的元素(即同属三个集合的)又如何?我们把它们加了三次,又减了三次,结果它们一次都还没被数到。因此,最后要把这些元素重新加回来。

Returning to our example above, we have $|A| = 12\text{,}$ $|B| = 5\text{,}$ $|C| = 8\text{.}$ We also have $|A \cap B| = 2\text{,}$ $|A \cap C| = 6\text{,}$ $|B \cap C| = 3\text{,}$ and $|A \cap B \cap C| = 1\text{.}$ Therefore:

回到上面的例子,我们有 $|A| = 12\text{、}$$|B| = 5\text{、}$$|C| = 8\text{。}$ 还有 $|A \cap B| = 2\text{、}$$|A \cap C| = 6\text{、}$$|B \cap C| = 3\text{、}$$|A \cap B \cap C| = 1\text{。}$ 于是:

$\begin{equation*} |A \cup B \cup C| = 12 + 5 + 8 - 2 - 6 - 3 + 1 = 15 \end{equation*}$

This is what we got when we solved the problem using Venn diagrams.

这与我们用维恩图解出该题时得到的结果一致。

This process of adding in, then taking out, then adding back in, and so on is called the Principle of Inclusion/Exclusion, or simply PIE. We will return to this counting technique later to solve for more complicated problems (involving more than 3 sets).

这种「先加进来,再减出去,再加回来……」的过程称为容斥原理(Principle of Inclusion/Exclusion),简称 PIE。稍后我们会再次用到这一计数技巧,去解决更复杂的问题(涉及 3 个以上集合的情形)。