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

3.1 Propositional Logic 命题逻辑

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

Investigate! 探究!

You stumble upon two trolls playing Stratego®. They tell you:

你偶然遇到两只正在玩 Stratego®(战略棋)的巨魔。它们对你说:

Could both trolls be knights? Recall that all trolls are either always-truth-telling knights or always-lying knaves.

两只巨魔可能都是骑士吗?记住,所有巨魔要么是永远说真话的骑士,要么是一贯说谎的无赖。

A proposition is simply a statement. Propositional logic studies the ways statements can interact with each other. It is important to remember that propositional logic does not really care about the content of the statements. For example, in terms of propositional logic, the claims, “if the moon is made of cheese then basketballs are round,” and “if spiders have eight legs then Sam walks with a limp” are exactly the same. They are both implications: statements of the form, \(P \imp Q\text{.}\)

命题(proposition)就是一条陈述(statement)。命题逻辑研究的是命题之间相互作用的方式。重要的是要记住:命题逻辑并不真正关心命题的内容。例如,就命题逻辑而言,「如果月亮由奶酪做成,那么篮球是圆的」与「如果蜘蛛有八条腿,那么萨姆走路一瘸一拐」这两种说法完全相同。它们都是蕴涵:即形如 \(P \imp Q\text{.}\) 的命题。

Truth Tables 真值表

Here's a question about playing Monopoly:

下面是一道关于大富翁游戏的问题:

If you get more doubles than any other player then you will lose, or if you lose then you must have bought the most properties.

如果你掷出的「双数」比任何对手都多,那么你会输;或者,如果你输了,那么你一定买了最多的地产。

True or false? We will answer this question, and won't need to know anything about Monopoly. Instead we will look at the logical form of the statement.

真假与否?我们将回答这个问题,而且无需了解任何大富翁的规则。我们要考察的是这个命题的逻辑形式。

We need to decide when the statement \((P \imp Q) \vee (Q \imp R)\) is true. Using the definitions of the connectives in Section 0.2, we see that for this to be true, either \(P \imp Q\) must be true or \(Q \imp R\) must be true (or both). Those are true if either \(P\) is false or \(Q\) is true (in the first case) and \(Q\) is false or \(R\) is true (in the second case). So—yeah, it gets kind of messy. Luckily, we can make a chart to keep track of all the possibilities. Enter truth tables. The idea is this: on each row, we list a possible combination of T's and F's (for true and false) for each of the sentential variables, and then mark down whether the statement in question is true or false in that case. We do this for every possible combination of T's and F's. Then we can clearly see in which cases the statement is true or false. For complicated statements, we will first fill in values for each part of the statement, as a way of breaking up our task into smaller, more manageable pieces.

我们需要判断命题 \((P \imp Q) \vee (Q \imp R)\) 在何时为真。利用 0.2 节中联结词的定义可知,要使该命题为真,要么 \(P \imp Q\) 为真,要么 \(Q \imp R\) 为真(或二者皆真)。而前者在 \(P\) 为假或 \(Q\) 为真时为真,后者在 \(Q\) 为假或 \(R\) 为真时为真。所以——没错,这变得有点乱。幸好,我们可以画一张表来记录所有可能性。这就引出了真值表(truth tables)。思路如下:在每一行中,我们列出各个语句变元所有可能的 T(真)与 F(假)的组合,然后标明该命题在相应情况下为真还是为假。我们对 T 与 F 的每一种可能组合都这样做。于是就能清楚地看出该命题在哪些情况下为真、哪些情况下为假。对于复杂命题,我们会先分别填入命题各部分的真值,以此把任务拆成更小、更易处理的部分。

Since the truth value of a statement is completely determined by the truth values of its parts and how they are connected, all you really need to know is the truth tables for each of the logical connectives. Here they are:

由于一个命题的真值完全由其组成部分的真值以及它们的联结方式所决定,你真正需要掌握的,就是每一种逻辑联结词的真值表。它们如下:
$P$$Q$$P\wedge Q$
TTT
TFF
FTF
FFF
合取(conjunction)$P\wedge Q$ 的真值表:仅当 $P$ 与 $Q$ 同为真时 $P\wedge Q$ 才为真;其余三种情况(至少一个为假)均为假。
$P$$Q$$P\vee Q$
TTT
TFT
FTT
FFF
析取(disjunction,相容或)$P\vee Q$ 的真值表:只要 $P$、$Q$ 中至少一个为真(含二者皆真),$P\vee Q$ 就为真;仅当二者皆假时为假。
$P$$Q$$P\imp Q$
TTT
TFF
FTT
FFT
蕴涵(implication)$P\imp Q$ 的真值表:仅当 $P$ 为真且 $Q$ 为假时 $P\imp Q$ 为假;其余情况均为真。
$P$$Q$$P\iff Q$
TTT
TFF
FTF
FFT
双条件(biconditional,当且仅当)$P\iff Q$ 的真值表:$P$ 与 $Q$ 同真或同假时为真,一真一假时为假。

The truth table for negation looks like this:

否定(negation)的真值表如下:
$P$$\neg P$
TF
FT
否定(否命题运算)$\neg P$ 的真值表:$P$ 为真时 $\neg P$ 为假,$P$ 为假时 $\neg P$ 为真。

None of these truth tables should come as a surprise; they are all just restating the definitions of the connectives. Let's try another one.

这些真值表都不该令人意外——它们都只是把联结词的定义重述了一遍。我们再试一个。

Example 1

示例 1

Make a truth table for the statement \(\neg P \vee Q\text{.}\)

为命题 \(\neg P \vee Q\text{.}\) 制作一张真值表。

Solution

解答

Note that this statement is not \(\neg(P \vee Q)\text{,}\) the negation belongs to \(P\) alone. Here is the truth table:

注意,该命题并非 \(\neg(P \vee Q)\text{,}\)否定仅作用于 \(P\) 本身。真值表如下:
$P$$Q$$\neg P$$\neg P \vee Q$
TTFT
TFFF
FTTT
FFTT
$\neg P \vee Q$ 的真值表:先由 $P$ 列取反得到 $\neg P$ 列,再按析取规则结合 $Q$ 列得到末列。

We added a column for \(\neg P\) to make filling out the last column easier. The entries in the \(\neg P\) column were determined by the entries in the \(P\) column. Then to fill in the final column, look only at the column for \(Q\) and the column for \(\neg P\) and use the rule for \(\vee\text{.}\)

我们额外增加了一列 \(\neg P\),以便更容易填出最后一列。\(\neg P\) 列的取值由 \(P\) 列决定。接着,要填最后一列,只需看 \(Q\) 列与 \(\neg P\) 列,并套用 \(\vee\) 的规则即可。

Now let's answer our question about monopoly:

现在我们来回答关于大富翁的那个问题:

Example 2

示例 2

Analyze the statement, “if you get more doubles than any other player you will lose, or that if you lose you must have bought the most properties,” using truth tables.

用真值表分析这个命题:「如果你掷出的双数比任何对手都多,那么你会输;或者,如果你输了,那么你一定买了最多的地产。」

Solution

解答

Represent the statement in symbols as \((P \imp Q) \vee (Q \imp R)\text{,}\) where \(P\) is the statement “you get more doubles than any other player,” \(Q\) is the statement “you will lose,” and \(R\) is the statement “you must have bought the most properties.” Now make a truth table.

把该命题符号化为 \((P \imp Q) \vee (Q \imp R)\text{,}\)其中 \(P\) 表示「你掷出的双数比任何对手都多」,\(Q\) 表示「你会输」,\(R\) 表示「你一定买了最多的地产」。现在制作一张真值表。

The truth table needs to contain 8 rows in order to account for every possible combination of truth and falsity among the three statements. Here is the full truth table:

真值表需要 8 行,以涵盖三个命题真假的所有可能组合。下面是完整的真值表:
$P$$Q$$R$$P \imp Q$$Q \imp R$$(P \imp Q) \vee (Q \imp R)$
TTTTTT
TTFTFT
TFTFTT
TFFFTT
FTTTTT
FTFTFT
FFTTTT
FFFTTT
$(P \imp Q) \vee (Q \imp R)$ 的完整真值表(三变元共 8 行):前 3 列为 $P,Q,R$ 的全体真假组合,第 4、5 列分别由蕴涵定义得出,末列按析取规则由前两列合并得到。可见末列全为 T,故该命题恒真。

The first three columns are simply a systematic listing of all possible combinations of T and F for the three statements (do you see how you would list the 16 possible combinations for four statements?). The next two columns are determined by the values of \(P\text{,}\) \(Q\text{,}\) and \(R\) and the definition of implication. Then, the last column is determined by the values in the previous two columns and the definition of \(\vee\text{.}\) It is this final column we care about.

前 3 列只是对三个命题所有可能的 T、F 组合所作的系统性列举(你能想出四个命题时如何列出 16 种组合吗?)。接下来的两列由 $P$、$Q$、$R$ 的取值与蕴涵的定义决定。然后,最后一列由前两列的取值与 $\vee$ 的定义决定。我们关心的正是这最后一列。

Notice that in each of the eight possible cases, the statement in question is true. So our statement about monopoly is true (regardless of how many properties you own, how many doubles you roll, or whether you win or lose).

注意,在八种可能的情形里,该命题每一次都为真。所以关于大富翁的那个命题为真(无论你拥有多少地产、掷出多少次双数,或者你究竟赢还是输)。

The statement about monopoly is an example of a tautology, a statement which is true on the basis of its logical form alone. Tautologies are always true but they don't tell us much about the world. No knowledge about monopoly was required to determine that the statement was true. In fact, it is equally true that “If the moon is made of cheese, then Elvis is still alive, or if Elvis is still alive, then unicorns have 5 legs.”

关于大富翁的这个命题是一个重言式(tautology)的例子——一种仅因其逻辑形式就为真的命题。重言式永远为真,但它们并不能告诉我们关于世界的多少信息。要判断该命题为真,根本不需要任何大富翁知识。事实上,下面这句话同样为真:「如果月亮由奶酪做成,那么猫王还活着;或者,如果猫王还活着,那么独角兽有 5 条腿。」

Logical Equivalence 逻辑等价

You might have noticed that the final column in the truth table from \(\neg P \vee Q\) is identical to the final column in the truth table for \(P \imp Q\text{:}\)

你可能已经注意到,$\neg P \vee Q$ 那张真值表的最后一列,与 $P \imp Q$ 真值表的最后一列完全相同:
$P$$Q$$P \imp Q$$\neg P \vee Q$
TTTT
TFFF
FTTT
FFTT
$\neg P \vee Q$ 与 $P \imp Q$ 的真值表对比:两命题所在列在四种赋值下完全一致。

This says that no matter what \(P\) and \(Q\) are, the statements \(\neg P \vee Q\) and \(P \imp Q\) either both true or both false. We therefore say these statements are logically equivalent.

这说明,无论 $P$、$Q$ 取何值,$\neg P \vee Q$ 与 $P \imp Q$ 这两个命题要么同真、要么同假。因此我们称这两个命题在逻辑上等价。

Logical Equivalence 逻辑等价

Two (molecular) statements \(P\) and \(Q\) are logically equivalent provided \(P\) is true precisely when \(Q\) is true. That is, \(P\) and \(Q\) have the same truth value under any assignment of truth values to their atomic parts.

若命题 $P$ 为真当且仅当 $Q$ 为真,则称两个(复合)命题 $P$ 与 $Q$ 逻辑等价(logically equivalent)。换言之,在对它们的原子部分作任意真值指派下,$P$ 与 $Q$ 都有相同的真值。

To verify that two statements are logically equivalent, you can make a truth table for each and check whether the columns for the two statements are identical.

要验证两个命题逻辑等价,可分别为二者制作真值表,并检查两命题所在的列是否完全一致。

Recognizing two statements as logically equivalent can be very helpful. Rephrasing a mathematical statement can often lends insight into what it is saying, or how to prove or refute it. Using truth tables we can systematically verify that two statements are indeed logically equivalent.

识别两个命题的逻辑等价往往很有帮助。重述一个数学命题,常能让人更透彻地理解它在说什么、或该如何证明与反驳它。借助真值表,我们可以系统地验证两个命题确实逻辑等价。

Example 3

示例 3

Are the statements, “it will not rain or snow” and “it will not rain and it will not snow” logically equivalent?

「不会下雨也不会下雪」与「不会下雨且不会下雪」这两个命题是否逻辑等价?

Solution

解答

We want to know whether \(\neg(P \vee Q)\) is logically equivalent to \(\neg P \wedge \neg Q\text{.}\) Make a truth table which includes both statements:

我们想知道 $\neg(P \vee Q)$ 是否与 $\neg P \wedge \neg Q$ 逻辑等价。制作一张包含两个命题的真值表:
$P$$Q$$\neg(P \vee Q)$$\neg P \wedge \neg Q$
TTFF
TFFF
FTFF
FFTT
$\neg(P \vee Q)$ 与 $\neg P \wedge \neg Q$ 的真值表:二者在四种赋值下真值完全一致,故逻辑等价。

Since in every row the truth values for the two statements are equal, the two statements are logically equivalent.

由于每一行中两个命题的真值都相等,故二者逻辑等价。

Notice that this example gives us a way to “distribute” a negation over a disjunction (an “or”). We have a similar rule for distributing over conjunctions (“and”s):

注意,这个例子给出了一种把否定「分配」到析取(「或」)之上的方法。对合取(「且」)也有类似的分配规则:

De Morgan's Laws 德摩根律

$\begin{equation*} \neg(P \wedge Q) \text{ is logically equivalent to } \neg P \vee \neg Q. \end{equation*}$

$\begin{equation*} \neg(P \vee Q) \text{ is logically equivalent to } \neg P \wedge \neg Q. \end{equation*}$

德摩根律(De Morgan's laws):合取的否定等价于各自否定的析取,析取的否定等价于各自否定的合取。

This suggests there might be a sort of “algebra” you could apply to statements (okay, there is: it is called Boolean algebra) to transform one statement into another. We can start collecting useful examples of logical equivalence, and apply them in succession to a statement, instead of writing out a complicated truth table. We will probably also want a way to deal with double negation:

这表明,或许存在某种可以施加于命题的「代数」(确实有,叫作布尔代数),能把一个命题变形为另一个。我们可以开始收集有用的逻辑等价式,并连续套用它们来化简命题,而不必写出一张复杂的真值表。我们大概还需要一种处理双重否定的办法:

Double Negation 双重否定

$\begin{equation*} \neg \neg P \mbox{ is logically equivalent to } P. \end{equation*}$

双重否定(double negation):$\neg\neg P$ 与 $P$ 逻辑等价。

Example: “It is not the case that \(c\) is not odd” means “\(c\) is odd.”

例:「并非『$c$ 不是奇数』」意为「$c$ 是奇数」。

Let's see how we can apply the equivalences we have encountered so far.

我们来看如何运用目前已遇到的等价式。

Example 4

示例 4

Prove that the statements \(\neg(P \imp Q)\) and \(P\wedge \neg Q\) are logically equivalent without using truth tables.

不使用真值表,证明 $\neg(P \imp Q)$ 与 $P\wedge \neg Q$ 逻辑等价。

Solution

解答

We want to start with one of the statements, and transform it into the other through a sequence of logically equivalent statements. Start with \(\neg(P \imp Q)\text{.}\) We can rewrite the implication as a disjunction this is logically equivalent to

我们从一个命题出发,通过一连串逻辑等价的变形把它变成另一个。从 $\neg(P \imp Q)$ 开始。可先把蕴涵改写为等价的析取形式:

$\begin{equation*} \neg(\neg P \vee Q). \end{equation*}$

Now apply DeMorgan's law to get

再运用德摩根律得到

$\begin{equation*} \neg\neg P \wedge \neg Q. \end{equation*}$

Finally, use double negation to arrive at \(P \wedge \neg Q\)

最后用双重否定化简为 \(P \wedge \neg Q\)

Notice that the above example illustrates that the negation of an implication is NOT an implication: it is a conjunction!

注意,上例说明:一个蕴涵的否定并不是蕴涵,而是合取!

To verify that two statements are logically equivalent, you can use truth tables or a sequence of logically equivalent replacements. The truth table method, although cumbersome, has the advantage that it can verify that two statements are NOT logically equivalent.

要验证两个命题逻辑等价,可用真值表,也可用一连串逻辑等价替换。真值表法虽繁琐,其优势在于能验明两个命题并「不」逻辑等价。

Example 5

示例 5

Are the statements \((P \vee Q) \imp R\) and \((P \imp R) \vee (Q \imp R)\) logically equivalent?

$(P \vee Q) \imp R$ 与 $(P \imp R) \vee (Q \imp R)$ 是否逻辑等价?

Solution

解答

Note that while we could start rewriting these statements with logically equivalent replacements in the hopes of transforming one into another, we will never be sure that our failure is due to their lack of logical equivalence rather than our lack of imagination. So instead, let's make a truth table:

注意,尽管我们可以试着用逻辑等价替换来改写这两个命题,指望把其中一个变成另一个,但我们永远无法确定:改写失败究竟是因为它们本不等价,还是因为我们思路不够巧。所以,我们改画一张真值表:
$P$$Q$$R$$(P\vee Q) \imp R$$(P\imp R) \vee (Q \imp R)$
TTTTT
TTFFF
TFTTT
TFFFT
FTTTT
FTFFT
FFTTT
FFFTT
两命题的 8 行真值表:第 4 行与第 6 行中 $(P\vee Q)\imp R$ 为假而 $(P\imp R)\vee(Q\imp R)$ 为真,故二者并不逻辑等价。

Look at the fourth (or sixth) row. In this case, \((P \imp R) \vee (Q \imp R)\) is true, but \((P \vee Q) \imp R\) is false. Therefore the statements are not logically equivalent.

看第 4 行(或第 6 行)。在这一行,$(P \imp R) \vee (Q \imp R)$ 为真,而 $(P \vee Q) \imp R$ 为假。因此这两个命题并不逻辑等价。

While we don't have logical equivalence, it is the case that whenever \((P \vee Q) \imp R\) is true, so is \((P \imp R) \vee (Q \imp R)\text{.}\) This tells us that we can deduce \((P \imp R) \vee (Q \imp R)\) from \((P \vee Q) \imp R\text{,}\) just not the reverse direction.

虽然二者不等价,但确实有:只要 $(P \vee Q) \imp R$ 为真,$(P \imp R) \vee (Q \imp R)$ 也为真。这说明我们可由 $(P \vee Q) \imp R$ 推出 $(P \imp R) \vee (Q \imp R)$,只是反过来不行。

Deductions 推理(演绎)

Investigate!

探究!

Holmes owns two suits: one black and one tweed. He always wears either a tweed suit or sandals. Whenever he wears his tweed suit and a purple shirt, he chooses to not wear a tie. He never wears the tweed suit unless he is also wearing either a purple shirt or sandals. Whenever he wears sandals, he also wears a purple shirt. Yesterday, Holmes wore a bow tie. What else did he wear?

福尔摩斯有两套西装:一套黑色,一套斜纹软呢。他总是穿斜纹软呢西装,或穿凉鞋。只要他穿斜纹软呢西装并配紫色衬衫,他就选择不打领带。除非同时穿着紫色衬衫或凉鞋,否则他绝不穿斜纹软呢西装。每当他穿凉鞋时,他也穿紫色衬衫。昨天,福尔摩斯戴了领结。他还穿了些什么?

Earlier we claimed that the following was a valid argument:

此前我们断言下面这个论证有效:

If Edith eats her vegetables, then she can have a cookie. Edith ate her vegetables. Therefore Edith gets a cookie.

如果伊迪丝吃了蔬菜,那么她可以吃一块饼干。伊迪丝吃了蔬菜。因此伊迪丝得到一块饼干。

How do we know this is valid? Let's look at the form of the statements. Let \(P\) denote “Edith eats her vegetables” and \(Q\) denote “Edith can have a cookie.” The logical form of the argument is then:

我们怎么知道它有效?来看这些命题的形式。令 $P$ 表示「伊迪丝吃了蔬菜」,$Q$ 表示「伊迪丝可以吃一块饼干」。该论证的逻辑形式便是:
$P \imp Q$
$P$
$\therefore$$Q$
推理形式:前提为 $P\imp Q$ 与 $P$,结论为 $Q$,即「肯定前件」(modus ponens)。

This is an example of a deduction rule, an argument form which is always valid. This one is a particularly famous rule called modus ponens. Are you convinced that it is a valid deduction rule? If not, consider the following truth table:

这是一个推理规则(deduction rule)的例子——一种永远有效的论证形式。这条规则特别著名,叫作「肯定前件」(modus ponens)。你是否相信它是有效的推理规则?若不信,请看下面这张真值表:
$P$$Q$$P\imp Q$
TTT
TFF
FTT
FFT
$P\imp Q$ 真值表:仅当 $P$ 真、且 $P\imp Q$ 与 $P$ 同时为真时(第 1 行),$Q$ 亦为真,故该推理规则有效。

This is just the truth table for \(P \imp Q\text{,}\) but what matters here is that all the lines in the deduction rule have their own column in the truth table. Remember that an argument is valid provided the conclusion must be true given that the premises are true. The premises in this case are \(P \imp Q\) and \(P\text{.}\) Which rows of the truth table correspond to both of these being true? \(P\) is true in the first two rows, and of those, only the first row has \(P \imp Q\) true as well. And lo-and-behold, in this one case, \(Q\) is also true. So if \(P\imp Q\) and \(P\) are both true, we see that \(Q\) must be true as well.

这其实就是 $P \imp Q$ 的真值表,但关键在于:推理规则中的每一行在真值表里都有自己的一列。记住,所谓论证有效,是指当前提为真时,结论必然为真。此例中的前提是 $P \imp Q$ 与 $P$。真值表中哪些行对应这两者同时为真?$P$ 在第 1、2 行为真,而其中只有第 1 行 $P \imp Q$ 也为真。看哪,在仅有的这一行里,$Q$ 同样为真。所以,若 $P\imp Q$ 与 $P$ 均为真,则 $Q$ 必为真。

Here are a few more examples.

再看几个例子。

Example 6

示例 6

Show that

证明
$P \imp Q$
$\neg P \imp Q$
$\therefore$$Q$
待证推理形式:前提为 $P\imp Q$ 与 $\neg P\imp Q$,结论为 $Q$。

is a valid deduction rule.

是一个有效的推理规则。

Solution

解答

We make a truth table which contains all the lines of the argument form:

我们制作一张真值表,包含该论证形式的全部行:
$P$$Q$$P\imp Q$$\neg P$$\neg P \imp Q$
TTTFT
TFFFT
FTTTT
FFTTF
$P, \neg P\imp Q$ 等真值表:仅第 1、3 行两个前提同真,而这两行 $Q$ 亦为真,故该推理规则有效。

(we include a column for \(\neg P\) just as a step to help getting the column for \(\neg P \imp Q\).

(我们加入一列 $\neg P$,只是作为求 $\neg P \imp Q$ 列的中间步骤。)

Now look at all the rows for which both \(P \imp Q\) and \(\neg P \imp Q\) are true. This happens only in rows 1 and 3. Hey! In those rows \(Q\) is true as well, so the argument form is valid (it is a valid deduction rule).

现在看 $P \imp Q$ 与 $\neg P \imp Q$ 同时为真的所有行。这只在第 1 行与第 3 行发生。瞧!在这两行中 $Q$ 也为真,所以该论证形式有效(它是一个有效的推理规则)。

Example 7

示例 7

Decide whether

判断
$P \imp R$
$Q \imp R$
$R$
$\therefore$$P \vee Q$
待判断的推理形式:前提为 $P\imp R$、$Q\imp R$、$R$,结论为 $P\vee Q$。

is a valid deduction rule.

是否为有效的推理规则。

Solution

解答

Let's make a truth table containing all four statements.

我们来制作一张包含全部四个命题的真值表。
$P$$Q$$R$$P \imp R$$Q \imp R$$P \vee Q$
TTTTTT
TTFFFT
TFTTTT
TFFFTT
FTTTTT
FTFTFT
FFTTTF
FFFTTF
$P\imp R$、$Q\imp R$、$P\vee Q$ 等真值表:倒数第二行(第 7 行)三个前提同真而结论 $P\vee Q$ 为假,故该推理规则无效。

Look at the second to last row. Here all three premises of the argument are true, but the conclusion is false. Thus this is not a valid deduction rule.

看倒数第二行。在这里,论证的三个前提都为真,但结论为假。因此它不是有效的推理规则。

While we have the truth table in front of us, look at rows 1 and 5. These are the only rows in which all of the statements \(P \imp R\text{,}\) \(Q \imp R\text{,}\) and \(P\vee Q\) are true. It also happens that \(R\) is true in these rows as well. Thus we have discovered a new deduction rule we know is valid:

趁真值表就在眼前,再看第 1 行与第 5 行。只有在这两行中,$P \imp R$、$Q \imp R$ 与 $P\vee Q$ 同时为真。而恰好在这两行中 $R$ 也为真。于是我们发现了另一条已知有效的推理规则:
$P \imp R$
$Q \imp R$
$P \vee Q$
$\therefore$$R$
新发现的推理规则:前提为 $P\imp R$、$Q\imp R$、$P\vee Q$,结论为 $R$(有效)。

Beyond Propositions 超越命题

As we saw in Section 0.2, not every statement can be analyzed using logical connectives alone. For example, we might want to work with the statement:

正如我们在 0.2 节所见,并非每个命题都能仅靠逻辑联结词来分析。例如,我们可能想处理这样一个命题:

All primes greater than 2 are odd.

所有大于 2 的素数都是奇数。

To write this statement symbolically, we must use quantifiers. We can translate as follows:

要把这个命题符号化,必须用量词。我们可以这样翻译:

$\begin{equation*} \forall x ((P(x) \wedge x \gt 2) \imp O(x)). \end{equation*}$

符号化:对所有 $x$,若 $x$ 是素数且 $x>2$,则 $x$ 是奇数。

In this case, we are using \(P(x)\) to denote “\(x\) is prime” and \(O(x)\) to denote “\(x\) is odd.” These are not propositions, since their truth value depends on the input \(x\text{.}\) Better to think of \(P\) and \(O\) as denoting properties of their input. The technical term for these is predicates and when we study them in logic, we need to use predicate logic.

这里我们用 $P(x)$ 表示「$x$ 是素数」,$O(x)$ 表示「$x$ 是奇数」。它们不是命题,因为其真值依赖于输入 $x$。不如把 $P$ 与 $O$ 看作对其输入的性质的描述。这一技术称谓是谓词(predicate);当我们在逻辑中研究它们时,需要用到谓词逻辑(predicate logic)

It is important to stress that predicate logic extends propositional logic (much in the way quantum mechanics extends classical mechanics). You will notice that our statement above still used the (propositional) logical connectives. Everything that we learned about logical equivalence and deductions still applies. However, predicate logic allows us to analyze statements at a higher resolution, digging down into the individual propositions \(P\text{,}\) \(Q\text{,}\) etc.

必须强调:谓词逻辑拓展了命题逻辑(正如量子力学拓展了经典力学)。你会注意到,上面的命题仍然使用了(命题性的)逻辑联结词。我们所学关于逻辑等价与推理的一切仍然适用。不过,谓词逻辑让我们能以更高的分辨率分析命题,深入到单个命题 $P$、$Q$ 等的内部。

A full treatment of predicate logic is beyond the scope of this text. One reason is that there is no systematic procedure for deciding whether two statements in predicate logic are logically equivalent (i.e., there is no analogue to truth tables here). Rather, we end with a couple of examples of logical equivalence and deduction, to pique your interest.

对谓词逻辑的完整论述超出了本书范围。原因之一在于:没有系统的程序能判定谓词逻辑中两个命题是否等价(也就是说,这里没有与真值表对应的工具)。我们转而用几个关于逻辑等价与推理的例子作结,以激起你的兴趣。

Example 8

示例 8

Suppose we claim that there is no smallest number. We can translate this into symbols as

假设我们断言:不存在最小的数。可把它符号化为

$\begin{equation*} \neg \exists x \forall y (x \le y) \end{equation*}$

字面义:「并非存在一个数 $x$,使得对所有数 $y$,$x$ 都小于或等于 $y$。」

(literally, “it is not true that there is a number \(x\) such that for all numbers \(y\text{,}\) \(x\) is less than or equal to \(y\)”).

(即上面这句话的字面解释。)

However, we know how negation interacts with quantifiers: we can pass a negation over a quantifier by switching the quantifier type (between universal and existential). So the statement above should be logically equivalent to

然而,我们知道否定如何与量词相互作用:把否定移到量词之上时,要把量词的类型在「全称」与「存在」之间切换。因此,上面的命题应与下面的命题逻辑等价:

$\begin{equation*} \forall x \exists y (y \lt x). \end{equation*}$

对所有 $x$,都存在某个比 $x$ 更小的 $y$。

Notice that \(y \lt x\) is the negation of \(x \le y\text{.}\) This literally says, “for every number \(x\) there is a number \(y\) which is smaller than \(x\text{.}\)” We see that this is another way to make our original claim

注意,$y \lt x$ 恰是 $x \le y$ 的否定。这句话的字面义是:「对每个数 $x$,都存在一个比 $x$ 更小的数 $y$。」可见这是表达原断言的另一种方式。

Example 9

示例 9

Can you switch the order of quantifiers? For example, consider the two statements:

量词的顺序可以交换吗?例如,考虑下面两个命题:

$\begin{equation*} \forall x \exists y P(x,y) \qquad \mathrm{ and } \qquad \exists y \forall x P(x,y). \end{equation*}$

两个命题:$\forall x \exists y\, P(x,y)$ 与 $\exists y \forall x\, P(x,y)$。

Are these logically equivalent?

它们逻辑等价吗?

Solution

解答

These statements are NOT logically equivalent. To see this, we should provide an interpretation of the predicate \(P(x,y)\) which makes one of the statements true and the other false.

这两个命题并「不」逻辑等价。要看出这一点,我们只需给出谓词 $P(x,y)$ 的一种解释,使其中一个为真、另一个为假。

Let \(P(x,y)\) be the predicate \(x \lt y\text{.}\) It is true, in the natural numbers, that for all \(x\) there is some \(y\) greater than it (since there are infinitely many numbers). However, there is not a natural number \(y\) which is greater than every number \(x\text{.}\) Thus it is possible for \(\forall x \exists y P(x,y)\) to be true while \(\exists y \forall x P(x,y)\) is false.

令 $P(x,y)$ 为谓词 $x \lt y$。在自然数中,「对每个 $x$ 都存在某个比它大的 $y$」为真(因为数有无穷多个)。然而,并不存在某个比所有 $x$ 都大的自然数 $y$。因此完全可能出现 $\forall x \exists y P(x,y)$ 为真、而 $\exists y \forall x P(x,y)$ 为假的情形。

We cannot do the reverse of this though. If there is some \(y\) for which every \(x\) satisfies \(P(x,y)\text{,}\) then certainly for every \(x\) there is some \(y\) which satisfies \(P(x,y)\text{.}\) The first is saying we can find one \(y\) that works for every \(x\text{.}\) The second allows different \(y\)'s to work for different \(x\)'s, but there is nothing preventing us from using the same \(y\) that work for every \(x\text{.}\) In other words, while we don't have logical equivalence between the two statements, we do have a valid deduction rule:

不过反过来不成立。如果存在某个 $y$ 使得每个 $x$ 都满足 $P(x,y)$,那么对每个 $x$ 当然也存在某个满足 $P(x,y)$ 的 $y$。前者是说:能找到一个对一切 $x$ 都适用的 $y$;后者允许对不同的 $x$ 用不同的 $y$,但并没有禁止我们沿用那个对一切 $x$ 都适用的同一个 $y$。换言之,虽然这两个命题之间并不逻辑等价,但我们确实有一条有效的推理规则:
$\exists y \forall x P(x,y)$
$\therefore$$\forall x \exists y P(x,y)$
推理规则:由 $\exists y \forall x P(x,y)$ 可推出 $\forall x \exists y P(x,y)$(有效),但反之不成立。

Put yet another way, this says that the single statement

换一种说法,这意味着单个命题

$\begin{equation*} \exists y \forall x P(x,y) \imp \forall x \exists y P(x,y) \end{equation*}$

$\exists y \forall x P(x,y) \imp \forall x \exists y P(x,y)$

is always true. This is sort of like a tautology, although we reserve that term for necessary truths in propositional logic. A statement in predicate logic that is necessarily true gets the more prestigious designation of a law of logic (or sometimes logically valid, but that is less fun).

恒为真。这有点像重言式,不过「重言式」一词我们专留给命题逻辑中的必然真理。谓词逻辑中必然为真的命题,会被冠以更显赫的称号:逻辑定律(law of logic,有时也叫 logically valid,但那样就没趣了)。