本文属于「离散数学」系列文章之一。这一系列着重于离散数学的学习和应用。由于内容随时可能发生更新变动,欢迎关注和收藏离散数学系列文章汇总目录一文以作备忘。此外,在本系列学习文章中,为了透彻理解数学知识,本人参考了诸多博客、教程、文档、书籍等资料。以下是本文的不完全参考目录,在后续学习中还会逐渐补充:
- 离散数学及其应用 第七版
Discrete Mathematics and Its Applications 7th
,作者是Kenneth H.Rosen
- 离散数学 第二版,武波等编著,西安电子科技大学出版社
文章目录
6. 范式
从【离散数学】数理逻辑 第一章 命题逻辑(3) 逻辑等价与蕴含中,我们了解到,一个命题公式可能具有多种等价表达形式。为了方便研究,就要对命题公式规范化,两种规范化表示形式是:主析取范式和主合取范式。不过在此之前,我们需要了解文字、析取式、合取式、析取范式、合取范式等概念。
6.1 文字、析取式、合取式、析取范式、合取范式和求取方法
定义6.1.1 文字就是命题变元或命题变元的否定。例如, P P P、 ¬ R \lnot R ¬R 等都是文字。
定义6.1.2 仅由若干文字通过联结词 ∨ \vee ∨ 构成的命题公式称为析取式。例如, R R R、 ¬ R \lnot R ¬R、 S ∨ ¬ H S\vee \lnot H S∨¬H 等都是析取式。
定义6.1.3 仅由若干文字通过联结词 ∧ \wedge ∧ 构成的命题公式称为合取式。例如 R R R、 ¬ R \lnot R ¬R、 S ∧ ¬ H S\wedge \lnot H S∧¬H 等都是合取式。
定义6.1.4 一个命题公式称为析取范式 disjunctive normal form
,当且仅当它具有如下形式,其中的
A
1
,
A
2
,
…
,
A
n
A_1, A_2, \dots, A_n
A1,A2,…,An 都是合取式:
A
1
∨
A
2
∨
⋯
∨
A
n
(
n
≤
1
)
A_1 \vee A_2 \vee \dots \vee A_n \quad (n \le 1)
A1∨A2∨⋯∨An(n≤1)
定义6.1.5 一个命题公式称为合取范式 conjunctive normal form
,当且仅当它具有如下形式,其中的
A
1
,
A
2
,
…
,
A
n
A_1, A_2, \dots, A_n
A1,A2,…,An 都是析取式:
A
1
∧
A
2
∧
⋯
∧
A
n
(
n
≤
1
)
A_1 \wedge A_2 \wedge \dots \wedge A_n \quad (n\le 1)
A1∧A2∧⋯∧An(n≤1)
任何一个命题公式,都有等价的合取范式和析取范式。具体求解步骤如下:
- 将公式中的联结词都归约成 ¬ , ∨ , ∧ \lnot, \vee, \wedge ¬,∨,∧ ;
- 利用德摩根定律,将否定联结词 ¬ \lnot ¬ 直接移到各命题变元之前;
- 利用分配律、结合律,将公式归约成合取范式或析取范式。
例1 求出
¬
(
P
∨
Q
)
↔
(
P
∧
Q
)
\lnot (P\vee Q) \leftrightarrow (P \wedge Q)
¬(P∨Q)↔(P∧Q) 的合取范式和析取范式:
解答:
¬
(
P
∨
Q
)
↔
(
P
∧
Q
)
⇔
(
¬
(
P
∨
Q
)
→
(
P
∧
Q
)
)
∧
(
(
P
∧
Q
)
→
¬
(
P
∨
Q
)
)
⇔
(
(
P
∨
Q
)
∨
(
P
∧
Q
)
)
∧
(
¬
(
P
∧
Q
)
∨
¬
(
P
∨
Q
)
)
⇔
(
P
∨
Q
)
∧
(
(
¬
P
∨
¬
Q
)
∨
(
¬
P
∧
¬
Q
)
)
⇔
(
P
∨
Q
)
∧
(
¬
P
∨
¬
Q
)
合
取
范
式
⇔
(
¬
P
∧
Q
)
∨
(
P
∧
¬
Q
)
析
取
范
式
\begin{aligned} &\lnot (P\vee Q) \leftrightarrow (P\wedge Q)\\ &\Leftrightarrow (\lnot (P\vee Q) \to (P \wedge Q)) \wedge ((P \wedge Q) \to \lnot (P \vee Q)) \\ &\Leftrightarrow ((P\vee Q) \vee (P \wedge Q)) \wedge (\lnot (P \wedge Q) \vee \lnot (P \vee Q)) \\ &\Leftrightarrow (P \vee Q)\wedge ((\lnot P \vee \lnot Q) \vee (\lnot P \wedge \lnot Q)) \\ &\Leftrightarrow (P\vee Q) \wedge (\lnot P \vee \lnot Q) \quad \mathtt{合取范式} \\ &\Leftrightarrow (\lnot P \wedge Q) \vee (P \wedge \lnot Q) \quad \mathtt{析取范式} \end{aligned}
¬(P∨Q)↔(P∧Q)⇔(¬(P∨Q)→(P∧Q))∧((P∧Q)→¬(P∨Q))⇔((P∨Q)∨(P∧Q))∧(¬(P∧Q)∨¬(P∨Q))⇔(P∨Q)∧((¬P∨¬Q)∨(¬P∧¬Q))⇔(P∨Q)∧(¬P∨¬Q)合取范式⇔(¬P∧Q)∨(P∧¬Q)析取范式
显然,一个命题的析取范式和合取范式一定存在,但不一定是唯一的。为了将任意命题公式唯一地标准化,需要引入主范式。我们也会证明,为什么一个命题公式的主析取范式和主合取范式是唯一的。
6.2 主析取范式
6.2.1 极小项、编码及其性质
定义6.2.1 一个含
n
n
n 个命题变元的合取式,如果其中每个变元与其否定不同时存在、但两者之一必须出现且仅出现一次,则称该合取式为极小项 minterm
。
显然, n n n 个命题变元 P 1 , P 2 , … , P n P_1, P_2, \dots, P_n P1,P2,…,Pn 可构成 2 n 2^n 2n 个不同的极小项,具有如下形式,其中 P ~ i \widetilde P_i P i 可以是 P i P_i Pi 或者是 ¬ P i \lnot P_i ¬Pi : P ~ 1 ∧ P ~ 2 ∧ ⋯ ∧ P ~ n \widetilde P_1 \wedge \widetilde P_2 \wedge \dots \wedge \widetilde P_n P 1∧P 2∧⋯∧P n
对这一形式给出一个
n
n
n 位二进制编码(可以转换为十进制数)——当
P
~
i
\widetilde P_i
P
i 是
P
i
P_i
Pi 时,第
i
i
i 位取值为
1
1
1 ;当
P
~
i
\widetilde P_i
P
i 是
¬
P
i
\lnot P_i
¬Pi 时,第
i
i
i 位取值为
0
0
0 。以两个命题变元
P
,
Q
P, Q
P,Q 为例,编码如下:
{
m
0
=
m
00
=
¬
P
∧
¬
Q
m
1
=
m
01
=
¬
P
∧
Q
m
2
=
m
10
=
P
∧
¬
Q
m
3
=
m
11
=
P
∧
Q
\begin{cases} m_0 = m_{00} = \lnot P \wedge \lnot Q \\ m_1 = m_{01} = \lnot P \wedge Q\\ m_2 = m_{10} = P \wedge \lnot Q\\ m_3 = m_{11} = P \wedge Q \end{cases}
⎩⎪⎪⎪⎨⎪⎪⎪⎧m0=m00=¬P∧¬Qm1=m01=¬P∧Qm2=m10=P∧¬Qm3=m11=P∧Q
依次类推,含有
n
n
n 个命题变元
P
1
,
P
2
,
…
,
P
n
P_1, P_2, \dots, P_n
P1,P2,…,Pn 的极小项的编码为:
{
m
0
=
m
00
…
00
=
¬
P
1
∧
¬
P
2
∧
⋯
∧
¬
P
n
m
1
=
m
00
…
01
=
¬
P
1
∧
¬
P
2
∧
⋯
∧
¬
P
n
−
1
∧
P
n
…
m
2
n
−
1
=
m
11
…
1
=
P
1
∧
P
2
∧
⋯
∧
P
n
\begin{cases} m_0 = m_{00\dots00} = \lnot P_1 \wedge \lnot P_2 \land \dots \land \lnot P_n \\ m_1 = m_{00\dots01} =\lnot P_1 \wedge \lnot P_2 \land \dots \land \lnot P_{n - 1} \land P_n\\ \dots \\ m_{2^n-1} = m_{11\dots1} = P_1 \wedge P_2 \land \dots \land P_n \end{cases}
⎩⎪⎪⎪⎨⎪⎪⎪⎧m0=m00…00=¬P1∧¬P2∧⋯∧¬Pnm1=m00…01=¬P1∧¬P2∧⋯∧¬Pn−1∧Pn…m2n−1=m11…1=P1∧P2∧⋯∧Pn
再以两个命题变元 P , Q P, Q P,Q 为例,列出其和极小项的真值表。容易验证,没有两个极小项是等价的,且每个极小项都恰好对应 P , Q P, Q P,Q 的一组赋值使其为真:
P P P | Q Q Q | P ∧ Q P \land Q P∧Q | P ∧ ¬ Q P \land \lnot Q P∧¬Q | ¬ P ∧ Q \lnot P \land Q ¬P∧Q | ¬ P ∧ ¬ Q \lnot P \land \lnot Q ¬P∧¬Q |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 1 |
0 | 1 | 0 | 0 | 1 | 0 |
1 | 0 | 0 | 1 | 0 | 0 |
1 | 1 | 1 | 0 | 0 | 0 |
依次类推, n n n 个命题变元 P 1 , P 2 , … , P n P_1, P_2, \dots, P_n P1,P2,…,Pn 构成的极小项,具有以下性质:
- 每一个极小项,当其赋值与编码相同时,其真值为 T T T ;在其余 2 n − 1 2^n - 1 2n−1 种赋值下其真值均为 F F F ;
- 任意两个不同极小项的合取式永假,即 m i ∧ m j ⇔ F ( i ≠ j ) m_i \land m_j \Leftrightarrow F\quad (i \ne j) mi∧mj⇔F(i=j)
- 所有极小项的析取式永真,即: ∑ i = 0 2 n − 1 m i ⇔ m 0 ∨ m 1 ∨ ⋯ ∨ m 2 n − 1 ⇔ T \sum^{2^n -1 }_{i = 0} m_i \Leftrightarrow m_0 \lor m_1 \lor \dots \lor m_{2^n-1} \Leftrightarrow T i=0∑2n−1mi⇔m0∨m1∨⋯∨m2n−1⇔T
6.2.2 主析取范式和求取方法(真值表和逻辑推演)
定义6.2.2 设
P
1
,
P
2
,
…
,
P
n
P_1, P_2, \dots, P_n
P1,P2,…,Pn 是命题公式
A
A
A 中包含的所有命题变元,若由
P
1
,
P
2
,
…
,
P
n
P_1, P_2, \dots, P_n
P1,P2,…,Pn 的若干极小项析取构成的析取范式与
A
A
A 等价,则称该析取范式为
A
A
A 的主析取范式 principle disjunctive normal form
。
定理6.2.1 在一个命题公式
A
A
A 的真值表中,使
A
A
A 的真值为
T
T
T 的所有赋值对应的极小项析取构成的析取范式,即为
A
A
A 的主析取范式。
证明:设命题公式
A
A
A 的真值表中,
m
i
1
,
m
i
2
,
…
,
m
i
k
m_{i_1}, m_{i_2}, \dots, m_{i_k}
mi1,mi2,…,mik 为使命题公式
A
A
A 为真的赋值对应的所有极小项。下面只需证明
m
i
1
∨
m
i
2
∨
⋯
∨
m
i
k
⇔
A
m_{i_1} \lor m_{i_2} \lor \dots \lor m_{i_k} \Leftrightarrow A
mi1∨mi2∨⋯∨mik⇔A(回想等价关系的证明)。
- 对于 A A A 的任一赋值 t t t ,若 t t t 使得 A A A 为真,则赋值 t t t 对应的极小项属于 m i 1 , m i 2 , … , m i k m_{i_1} , m_{i_2} , \dots, m_{i_k} mi1,mi2,…,mik 之一,且该极小项也为真(极小项性质)。因而在该赋值 t t t 下, m i 1 ∨ m i 2 ∨ ⋯ ∨ m i k m_{i_1} \lor m_{i_2} \lor \dots \lor m_{i_k} mi1∨mi2∨⋯∨mik 的真值也为真;
- 对于 A A A 的任一赋值 t t t ,若 t t t 使得 A A A 为假,则赋值 t t t 对应的极小项不属于 m i 1 , m i 2 , … , m i k m_{i_1} , m_{i_2} , \dots, m_{i_k} mi1,mi2,…,mik 之一。因而在该赋值 t t t 下, m i 1 , m i 2 , … , m i k m_{i_1} , m_{i_2} , \dots, m_{i_k} mi1,mi2,…,mik 的真值均为假(极小项性质),即有 m i 1 ∨ m i 2 ∨ ⋯ ∨ m i k m_{i_1} \lor m_{i_2} \lor \dots \lor m_{i_k} mi1∨mi2∨⋯∨mik 的真值也为假;
- 因此,对于 A A A 的任一赋值,都有 A A A 与 m i 1 ∨ m i 2 ∨ ⋯ ∨ m i k m_{i_1} \lor m_{i_2} \lor \dots \lor m_{i_k} mi1∨mi2∨⋯∨mik 的真值相同,所以 m i 1 ∨ m i 2 ∨ ⋯ ∨ m i k ⇔ A m_{i_1} \lor m_{i_2} \lor \dots \lor m_{i_k} \Leftrightarrow A mi1∨mi2∨⋯∨mik⇔A(等价关系的定义)。
因此特别地,可以用构造真值表的方法,求出一个给定命题公式的主析取范式。由于一个命题公式的真值表是唯一的,所以由定理6.2.1知,一个命题公式的主析取范式也是唯一的。
例2 用构造真值表的方法,求命题公式
¬
P
∧
(
Q
→
R
)
\lnot P \land (Q \to R)
¬P∧(Q→R) 的主析取范式。
解答:构造真值表如下所示:
P P P | Q Q Q | R R R | ¬ P ∧ ( Q → R ) \lnot P \land (Q \to R) ¬P∧(Q→R) |
---|---|---|---|
0 | 0 | 0 | 1 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 0 |
所以
¬
P
∧
(
Q
→
R
)
\lnot P \land (Q \to R)
¬P∧(Q→R) 的主析取范式为:
(
¬
P
∧
¬
Q
∧
¬
R
)
∨
(
¬
P
∧
¬
Q
∧
R
)
∨
(
¬
P
∧
Q
∧
R
)
⇔
m
000
∨
m
001
∨
m
011
⇔
m
0
∨
m
1
∨
m
3
⇔
∑
(
0
,
1
,
3
)
\begin{aligned} &(\lnot P \land \lnot Q \land \lnot R) \lor (\lnot P \land \lnot Q \land R) \lor (\lnot P \land Q \land R) \\ \Leftrightarrow\ &m_{000} \lor m_{001} \lor m_{011} \\ \Leftrightarrow\ &m_0 \lor m_1 \lor m_3 \\ \Leftrightarrow\ &\sum(0, 1, 3) \end{aligned}
⇔ ⇔ ⇔ (¬P∧¬Q∧¬R)∨(¬P∧¬Q∧R)∨(¬P∧Q∧R)m000∨m001∨m011m0∨m1∨m3∑(0,1,3)
求一个命题公式的主析取范式,除了真值表方法,还有逻辑推演方法——即使用常见逻辑等价公式和替换规则、传递规则,求出它的主析取范式。原因在于,任何一个命题公式都可以求出它的析取范式,而析取范式可以转换为主析取范式。具体步骤如下:
- 将原命题公式转换为析取范式(上接求出析取范式的步骤);
- 将每个合取式等价变换为若干极小项的析取(即对每个合取式填补没有出现的变元,如缺少 P P P 和 ¬ P \lnot P ¬P ,则合取 ¬ P ∨ P \lnot P \lor P ¬P∨P ,再应用分配律展开成若干极小项的析取);
- 重复的极小项只保留一个。
例3 求命题公式
¬
P
∧
(
Q
→
R
)
\lnot P \land (Q \to R)
¬P∧(Q→R) 的主析取范式。
解答:
¬
P
∧
(
Q
→
R
)
⇔
¬
P
∧
(
¬
Q
∨
R
)
⇔
(
¬
P
∧
¬
Q
)
∨
(
¬
P
∧
R
)
析
取
范
式
⇔
(
¬
P
∧
¬
Q
∧
(
¬
R
∨
R
)
)
∨
(
¬
P
∧
(
¬
Q
∨
Q
)
∧
R
)
填
补
缺
失
变
元
⇔
(
¬
P
∧
¬
Q
∧
¬
R
)
∨
(
¬
P
∧
¬
Q
∧
R
)
∨
(
¬
P
∧
Q
∧
R
)
分
配
律
⇔
m
000
∨
m
001
∨
m
011
⇔
m
0
∨
m
1
∨
m
3
⇔
∑
(
0
,
1
,
3
)
\begin{aligned} &\lnot P \land (Q \to R) \\ \Leftrightarrow &\lnot P \land (\lnot Q \lor R)\\ \Leftrightarrow &(\lnot P \land \lnot Q) \lor (\lnot P \land R) \quad 析取范式\\ \Leftrightarrow &(\lnot P \land \lnot Q \land (\lnot R \lor R)) \lor (\lnot P \land (\lnot Q \lor Q) \land R) \quad {填补缺失变元} \\ \Leftrightarrow &(\lnot P \land \lnot Q \land \lnot R) \lor (\lnot P \land \lnot Q \land R) \lor (\lnot P \land Q \land R)\quad {分配律} \\ \Leftrightarrow\ &m_{000} \lor m_{001} \lor m_{011} \\ \Leftrightarrow\ &m_0 \lor m_1 \lor m_3 \\ \Leftrightarrow\ &\sum(0, 1, 3) \end{aligned}
⇔⇔⇔⇔⇔ ⇔ ⇔ ¬P∧(Q→R)¬P∧(¬Q∨R)(¬P∧¬Q)∨(¬P∧R)析取范式(¬P∧¬Q∧(¬R∨R))∨(¬P∧(¬Q∨Q)∧R)填补缺失变元(¬P∧¬Q∧¬R)∨(¬P∧¬Q∧R)∨(¬P∧Q∧R)分配律m000∨m001∨m011m0∨m1∨m3∑(0,1,3)
6.3 主合取范式
6.3.1 极大项、编码及其性质
定义6.3.1 一个含
n
n
n 个命题变元的析取式,如果其中每个变元与其否定不同时存在、但两者之一必须出现且仅出现一次,则称该析取式为极大项 maxterm
。
显然, n n n 个命题变元 P 1 , P 2 , … , P n P_1, P_2, \dots, P_n P1,P2,…,Pn 可构成 2 n 2^n 2n 个不同的极大项,具有如下形式,其中 P ~ i \widetilde P_i P i 可以是 P i P_i Pi 或者是 ¬ P i \lnot P_i ¬Pi : P ~ 1 ∨ P ~ 2 ∨ ⋯ ∨ P ~ n \widetilde P_1 \lor \widetilde P_2 \lor \dots \lor \widetilde P_n P 1∨P 2∨⋯∨P n
对这一形式也给出一个
n
n
n 位二进制编码(可以转换为十进制数)——当
P
~
i
\widetilde P_i
P
i 是
P
i
P_i
Pi 时,第
i
i
i 位取值为
0
0
0 ;当
P
~
i
\widetilde P_i
P
i 是
¬
P
i
\lnot P_i
¬Pi 时,第
i
i
i 位取值为
1
1
1 。以两个命题变元为例,编码如下(容易验证,没有两个极大项是等价的,且每个极大项都恰好对应
P
,
Q
P, Q
P,Q 的一组赋值使其为假):
{
M
0
=
M
00
=
P
∨
Q
M
1
=
M
01
=
P
∨
¬
Q
M
2
=
M
10
=
¬
P
∨
Q
M
3
=
M
11
=
¬
P
∨
¬
Q
\begin{cases} M_0 = M_{00} = P \lor Q \\ M_1 = M_{01} = P \lor \lnot Q\\ M_2 = M_{10} = \lnot P \lor Q\\ M_3 = M_{11} =\lnot P \lor \lnot Q \end{cases}
⎩⎪⎪⎪⎨⎪⎪⎪⎧M0=M00=P∨QM1=M01=P∨¬QM2=M10=¬P∨QM3=M11=¬P∨¬Q
依次类推,含有
n
n
n 个命题变元
P
1
,
P
2
,
…
,
P
n
P_1, P_2, \dots, P_n
P1,P2,…,Pn 的极大项的编码为:
{
M
0
=
M
00
…
00
=
P
1
∨
P
2
∨
⋯
∨
P
n
M
1
=
M
00
…
01
=
P
1
∨
P
2
∨
⋯
∨
P
n
−
1
∨
¬
P
n
…
M
2
n
−
1
=
M
11
…
1
=
¬
P
1
∨
¬
P
2
∨
⋯
∨
¬
P
n
\begin{cases} M_0 = M_{00\dots00} = P_1 \lor P_2 \lor \dots \lor P_n \\ M_1 = M_{00\dots01} = P_1 \lor P_2 \lor \dots \lor P_{n - 1} \lor \lnot P_n\\ \dots \\ M_{2^n-1} = M_{11\dots1} = \lnot P_1 \lor \lnot P_2 \lor \dots \lor \lnot P_n \end{cases}
⎩⎪⎪⎪⎨⎪⎪⎪⎧M0=M00…00=P1∨P2∨⋯∨PnM1=M00…01=P1∨P2∨⋯∨Pn−1∨¬Pn…M2n−1=M11…1=¬P1∨¬P2∨⋯∨¬Pn
再以两个命题变元 P , Q P, Q P,Q 为例,列出其和极大项的真值表。容易验证,没有两个极大项是等价的,且每个极大项都恰好对应 P , Q P, Q P,Q 的一组赋值使其为假:
P P P | Q Q Q | P ∨ Q P \lor Q P∨Q | P ∨ ¬ Q P \lor \lnot Q P∨¬Q | ¬ P ∨ Q \lnot P \lor Q ¬P∨Q | ¬ P ∨ ¬ Q \lnot P \lor \lnot Q ¬P∨¬Q |
---|---|---|---|---|---|
0 | 0 | 0 | 1 | 1 | 1 |
0 | 1 | 1 | 0 | 1 | 1 |
1 | 0 | 1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 | 1 | 0 |
依次类推, n n n 个命题变元 P 1 , P 2 , … , P n P_1, P_2, \dots, P_n P1,P2,…,Pn 构成的极大项,具有以下性质:
- 每一个极大项,当其赋值与编码相同时,其真值为 F F F ;在其余 2 n − 1 2^n - 1 2n−1 种赋值下其真值均为 T T T ;
- 任意两个不同极大项的析取式永真,即 M i ∨ M j ⇔ T ( i ≠ j ) M_i \lor M_j \Leftrightarrow T\quad (i \ne j) Mi∨Mj⇔T(i=j)
- 所有极大项的合取式永假,即: ∏ i = 0 2 n − 1 M i ⇔ M 0 ∧ M 1 ∧ ⋯ ∧ M 2 n − 1 ⇔ F \prod^{2^n -1 }_{i = 0} M_i \Leftrightarrow M_0 \land M_1 \land \dots \land M_{2^n-1} \Leftrightarrow F i=0∏2n−1Mi⇔M0∧M1∧⋯∧M2n−1⇔F
6.2.2 主合取范式和求取方法(真值表和逻辑推演)
定义6.3.2 设
P
1
,
P
2
,
…
,
P
n
P_1, P_2, \dots, P_n
P1,P2,…,Pn 是命题公式
A
A
A 中包含的所有命题变元,若由
P
1
,
P
2
,
…
,
P
n
P_1, P_2, \dots, P_n
P1,P2,…,Pn 的若干极大项合取构成的合取范式与
A
A
A 等价,则称该析取范式为
A
A
A 的主合取范式 principle conjunctive normal form
。
定理6.3.1 在一个命题公式
A
A
A 的真值表中,使
A
A
A 的真值为
F
F
F 的所有赋值对应的极大项合取构成的合取范式,即为
A
A
A 的主合取范式。
证明:设命题公式
A
A
A 的真值表中,
M
i
1
,
M
i
2
,
…
,
M
i
k
M_{i_1}, M_{i_2}, \dots, M_{i_k}
Mi1,Mi2,…,Mik 为使命题公式
A
A
A 为假的赋值对应的所有极大项。下面只需证明
M
i
1
∧
M
i
2
∧
⋯
∧
M
i
k
⇔
A
M_{i_1} \land M_{i_2} \land \dots \land M_{i_k} \Leftrightarrow A
Mi1∧Mi2∧⋯∧Mik⇔A(回想等价关系的证明)。
- 对于 A A A 的任一赋值 t t t ,若 t t t 使得 A A A 为假,则赋值 t t t 对应的极大项属于 M i 1 , M i 2 , … , M i k M_{i_1}, M_{i_2}, \dots, M_{i_k} Mi1,Mi2,…,Mik 之一,且该极大项也为假(极大项性质)。因而在该赋值 t t t 下, M i 1 ∧ M i 2 ∧ ⋯ ∧ M i k M_{i_1} \land M_{i_2} \land \dots \land M_{i_k} Mi1∧Mi2∧⋯∧Mik 的真值也为假;
- 对于 A A A 的任一赋值 t t t ,若 t t t 使得 A A A 为真,则赋值 t t t 对应的极大项不属于 M i 1 , M i 2 , … , M i k M_{i_1}, M_{i_2}, \dots, M_{i_k} Mi1,Mi2,…,Mik 之一。因而在该赋值 t t t 下, M i 1 , M i 2 , … , M i k M_{i_1}, M_{i_2}, \dots, M_{i_k} Mi1,Mi2,…,Mik 的真值均为真(极大项性质),即有 M i 1 ∧ M i 2 ∧ ⋯ ∧ M i k M_{i_1} \land M_{i_2} \land \dots \land M_{i_k} Mi1∧Mi2∧⋯∧Mik 的真值也为真;
- 因此,对于 A A A 的任一赋值,都有 A A A 与 M i 1 ∧ M i 2 ∧ ⋯ ∧ M i k M_{i_1} \land M_{i_2} \land \dots \land M_{i_k} Mi1∧Mi2∧⋯∧Mik 的真值相同,所以 M i 1 ∧ M i 2 ∧ ⋯ ∧ M i k ⇔ A M_{i_1} \land M_{i_2} \land \dots \land M_{i_k} \Leftrightarrow A Mi1∧Mi2∧⋯∧Mik⇔A(等价关系的定义)。
因此特别地,可以用构造真值表的方法,求出一个给定命题公式的主合取范式。由于一个命题公式的真值表是唯一的,所以由定理6.3.1知,一个命题公式的主合取范式也是唯一的。
例4 用构造真值表的方法,求命题公式
¬
P
∧
(
Q
→
R
)
\lnot P \land (Q \to R)
¬P∧(Q→R) 的主合取范式。
解答:构造真值表如下所示:
P P P | Q Q Q | R R R | ¬ P ∧ ( Q → R ) \lnot P \land (Q \to R) ¬P∧(Q→R) |
---|---|---|---|
0 | 0 | 0 | 1 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 0 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 0 |
所以
¬
P
∧
(
Q
→
R
)
\lnot P \land (Q \to R)
¬P∧(Q→R) 的主合取范式为:
(
P
∨
¬
Q
∨
R
)
∧
(
¬
P
∨
Q
∨
R
)
∧
(
¬
P
∨
Q
∨
¬
R
)
∧
(
¬
P
∨
¬
Q
∨
R
)
∧
(
¬
P
∨
¬
Q
∨
¬
R
)
⇔
M
010
∧
M
100
∧
M
101
∧
M
110
∧
M
111
⇔
M
2
∧
M
4
∧
M
5
∧
M
6
∧
M
7
⇔
∏
(
2
,
4
,
5
,
6
,
7
)
\begin{aligned} &(P \lor \lnot Q \lor R) \land (\lnot P \lor Q \lor R) \land (\lnot P \lor Q \lor \lnot R) \land (\lnot P \lor \lnot Q \lor R) \land (\lnot P \lor \lnot Q \lor \lnot R) \\ \Leftrightarrow\ &M_{010} \land M_{100} \land M_{101} \land M_{110} \land M_{111}\\ \Leftrightarrow\ &M_{2}\land M_{4} \land M_{5} \land M_{6} \land M_{7} \\ \Leftrightarrow\ &\prod(2, 4, 5, 6, 7) \end{aligned}
⇔ ⇔ ⇔ (P∨¬Q∨R)∧(¬P∨Q∨R)∧(¬P∨Q∨¬R)∧(¬P∨¬Q∨R)∧(¬P∨¬Q∨¬R)M010∧M100∧M101∧M110∧M111M2∧M4∧M5∧M6∧M7∏(2,4,5,6,7)
求一个命题公式的主合取范式,除了真值表方法,还有逻辑推演方法——即使用常见逻辑等价公式和替换规则、传递规则,求出它的主合取范式。原因在于,任何一个命题公式都可以求出它的合取范式,而合取范式可以转换为主合取范式。具体步骤如下:
- 将原命题公式转换为合取范式(上接求出合取范式的步骤);
- 将每个析取式等价变换为若干极大项的合取(即对每个析取式填补没有出现的变元,如缺少 P P P 和 ¬ P \lnot P ¬P ,则析取 ¬ P ∧ P \lnot P \land P ¬P∧P ,再应用分配律展开成若干极大项的合取);
- 重复的极大项只保留一个。
例5 求命题公式
¬
P
∧
(
Q
→
R
)
\lnot P \land (Q \to R)
¬P∧(Q→R) 的主合取范式。
解答:
¬
P
∧
(
Q
→
R
)
⇔
¬
P
∧
(
¬
Q
∨
R
)
合
取
范
式
⇔
(
¬
P
∨
(
Q
∧
¬
Q
)
∨
(
R
∧
¬
R
)
)
∧
(
(
P
∧
¬
P
)
∨
¬
Q
∨
R
)
填
补
缺
失
变
元
⇔
(
¬
P
∨
Q
∨
R
)
∧
(
¬
P
∨
¬
Q
∨
R
)
∧
(
¬
P
∨
Q
∨
¬
R
)
∧
(
¬
P
∨
¬
Q
∨
¬
R
)
∧
(
P
∨
¬
Q
∨
R
)
∧
(
¬
P
∨
¬
Q
∨
R
)
分
配
律
⇔
M
100
∧
M
110
∧
M
101
∧
M
111
∧
M
010
⇔
M
2
∧
M
4
∧
M
5
∧
M
6
∧
M
7
⇔
∏
(
2
,
4
,
5
,
6
,
7
)
\begin{aligned} &\lnot P \land (Q \to R) \\ \Leftrightarrow &\lnot P \land (\lnot Q \lor R) \quad 合取范式 \\ \Leftrightarrow &(\lnot P \lor (Q \land \lnot Q) \lor (R \land \lnot R)) \land ((P \land \lnot P) \lor \lnot Q \lor R) \quad {填补缺失变元}\\ \Leftrightarrow &(\lnot P \lor Q \lor R) \land (\lnot P \lor \lnot Q \lor R) \land (\lnot P \lor Q \lor \lnot R) \land (\lnot P \lor \lnot Q \lor \lnot R) \land (P \lor \lnot Q \lor R) \land (\lnot P \lor \lnot Q \lor R) \quad 分配律\\ \Leftrightarrow\ &M_{100} \land M_{110} \land M_{101} \land M_{111} \land M_{010} \\ \Leftrightarrow\ &M_{2} \land M_{4} \land M_{5} \land M_{6} \land M_{7} \\ \Leftrightarrow\ &\prod(2, 4, 5, 6, 7) \end{aligned}
⇔⇔⇔⇔ ⇔ ⇔ ¬P∧(Q→R)¬P∧(¬Q∨R)合取范式(¬P∨(Q∧¬Q)∨(R∧¬R))∧((P∧¬P)∨¬Q∨R)填补缺失变元(¬P∨Q∨R)∧(¬P∨¬Q∨R)∧(¬P∨Q∨¬R)∧(¬P∨¬Q∨¬R)∧(P∨¬Q∨R)∧(¬P∨¬Q∨R)分配律M100∧M110∧M101∧M111∧M010M2∧M4∧M5∧M6∧M7∏(2,4,5,6,7)
6.4 主析取范式和主合取范式的联系
由例2、3、4、5中发现,命题公式 ¬ P ∧ ( Q → R ) \lnot P \land (Q \to R) ¬P∧(Q→R) 的主析取范式为 ∑ ( 0 , 1 , 3 ) \sum (0, 1, 3) ∑(0,1,3) ,主合取范式为 ∏ ( 2 , 4 , 5 , 6 , 7 ) \prod (2, 4, 5, 6, 7) ∏(2,4,5,6,7) ,其中代表极小项和极大项的下标是互补的。这种互补性对所有命题公式都成立,从主析取范式和主合取范式的真值表求法不难验证这一点。
定理6.4.1 已知由
n
n
n 个不同命题变元构成的命题公式
A
A
A 的主析取范式为
∑
(
i
1
,
i
2
,
…
,
i
k
)
\sum (i_1, i_2, \dots, i_k)
∑(i1,i2,…,ik) ,其主合取范式为
∏
(
j
1
,
j
2
,
…
,
j
t
)
\prod (j_1, j_2, \dots, j_t)
∏(j1,j2,…,jt) ,则有:
{
i
1
,
i
2
,
…
,
i
k
}
∪
{
j
1
,
j
2
,
…
,
j
t
}
=
{
0
,
1
,
2
,
…
,
2
n
−
1
}
{
i
1
,
i
2
,
…
,
i
k
}
∩
{
j
1
,
j
2
,
…
,
j
t
}
=
∅
\begin{aligned} \{ i_1, i_2, \dots, i_k\} \cup \{j_1, j_2, \dots, j_t\} &= \{0, 1, 2, \dots, 2^n - 1\} \\ \{ i_1, i_2, \dots, i_k\} \cap \{j_1, j_2, \dots, j_t\} &= \varnothing \end{aligned}
{i1,i2,…,ik}∪{j1,j2,…,jt}{i1,i2,…,ik}∩{j1,j2,…,jt}={0,1,2,…,2n−1}=∅
证明:由于命题公式
A
A
A 的主析取范式为
∑
(
i
1
,
i
2
,
…
,
i
k
)
\sum (i_1, i_2, \dots, i_k)
∑(i1,i2,…,ik) ,主合取范式为
∏
(
j
1
,
j
2
,
…
,
j
t
)
\prod (j_1, j_2, \dots, j_t)
∏(j1,j2,…,jt) ,则有
A
⇔
∑
(
i
1
,
i
2
,
…
,
i
k
)
A \Leftrightarrow \sum (i_1, i_2, \dots, i_k)
A⇔∑(i1,i2,…,ik) 且
A
⇔
∏
(
j
1
,
j
2
,
…
,
j
t
)
A \Leftrightarrow \prod (j_1, j_2, \dots, j_t)
A⇔∏(j1,j2,…,jt) 。由此可得:
A
⇔
m
i
1
∨
m
i
2
∨
⋯
∨
m
i
k
A
⇔
M
j
1
∧
M
j
2
∧
⋯
∧
M
j
t
\begin{aligned} A \Leftrightarrow\ &m_{i_1}\lor m_{i_2}\lor \dots \lor m_{i_k} \\ A \Leftrightarrow\ &M_{j_1}\land M_{j_2}\land \dots \land M_{j_t} \end{aligned}
A⇔ A⇔ mi1∨mi2∨⋯∨mikMj1∧Mj2∧⋯∧Mjt
则有:
¬
A
⇔
¬
m
i
1
∧
¬
m
i
2
∧
⋯
∧
¬
m
i
k
⇔
M
i
1
∧
M
i
2
∧
⋯
∧
M
i
k
¬
A
⇔
¬
M
j
1
∨
¬
M
j
2
∨
⋯
∨
¬
M
j
t
⇔
m
j
1
∨
m
j
2
∨
⋯
∨
m
j
t
\begin{aligned} \lnot A \Leftrightarrow\ &\lnot m_{i_1}\land \lnot m_{i_2}\land \dots \land \lnot m_{i_k} \Leftrightarrow\ M_{i_1}\land M_{i_2}\land \dots \land M_{i_k} \\ \lnot A \Leftrightarrow\ &\lnot M_{j_1}\lor \lnot M_{j_2}\lor \dots \lor \lnot M_{j_t} \Leftrightarrow\ m_{j_1}\lor m_{j_2}\lor \dots \lor m_{j_t} \end{aligned}
¬A⇔ ¬A⇔ ¬mi1∧¬mi2∧⋯∧¬mik⇔ Mi1∧Mi2∧⋯∧Mik¬Mj1∨¬Mj2∨⋯∨¬Mjt⇔ mj1∨mj2∨⋯∨mjt
因为
A
∨
¬
A
⇔
(
m
i
1
∨
m
i
2
∨
⋯
∨
m
i
k
)
∨
(
m
j
1
∨
m
j
2
∨
⋯
∨
m
j
t
)
⇔
T
A \lor \lnot A \Leftrightarrow (m_{i_1}\lor m_{i_2}\lor \dots \lor m_{i_k}) \lor (m_{j_1}\lor m_{j_2}\lor \dots \lor m_{j_t}) \Leftrightarrow T
A∨¬A⇔(mi1∨mi2∨⋯∨mik)∨(mj1∨mj2∨⋯∨mjt)⇔T(相当于得到了所有极小项的析取),所以有:
{
i
1
,
i
2
,
…
,
i
k
}
∪
{
j
1
,
j
2
,
…
,
j
t
}
=
{
0
,
1
,
2
,
…
,
2
n
−
1
}
\{ i_1, i_2, \dots, i_k\} \cup \{j_1, j_2, \dots, j_t\} = \{0, 1, 2, \dots, 2^n - 1\}
{i1,i2,…,ik}∪{j1,j2,…,jt}={0,1,2,…,2n−1}
又因为:
A
∧
¬
A
⇔
(
m
i
1
∨
m
i
2
∨
⋯
∨
m
i
k
)
∧
(
m
j
1
∨
m
j
2
∨
⋯
∨
m
j
t
)
⇔
(
m
i
1
∧
m
j
1
)
∨
(
m
i
1
∧
m
j
2
)
∨
⋯
∨
(
m
i
1
∧
m
j
t
)
∨
(
m
i
2
∧
m
j
1
)
∨
(
m
i
2
∧
m
j
2
)
∨
⋯
∨
(
m
i
2
∧
m
j
t
)
∨
⋯
∨
(
m
i
k
∧
m
j
1
)
∨
(
m
i
k
∧
m
j
2
)
∨
⋯
∨
(
m
i
k
∧
m
j
t
)
⇔
F
\begin{aligned} A \land \lnot A &\Leftrightarrow (m_{i_1}\lor m_{i_2}\lor \dots \lor m_{i_k}) \land (m_{j_1}\lor m_{j_2}\lor \dots \lor m_{j_t})\\ &\Leftrightarrow\ (m_{i_1} \land m_{j_1}) \lor (m_{i_1} \land m_{j_2}) \lor \dots \lor (m_{i_1} \land m_{j_t}) \\ & \quad \lor (m_{i_2} \land m_{j_1}) \lor (m_{i_2} \land m_{j_2}) \lor \dots \lor (m_{i_2} \land m_{j_t}) \\ & \quad \lor \dots \lor (m_{i_k} \land m_{j_1}) \lor (m_{i_k} \land m_{j_2}) \lor \dots \lor (m_{i_k} \land m_{j_t}) \\ &\Leftrightarrow F \end{aligned}
A∧¬A⇔(mi1∨mi2∨⋯∨mik)∧(mj1∨mj2∨⋯∨mjt)⇔ (mi1∧mj1)∨(mi1∧mj2)∨⋯∨(mi1∧mjt)∨(mi2∧mj1)∨(mi2∧mj2)∨⋯∨(mi2∧mjt)∨⋯∨(mik∧mj1)∨(mik∧mj2)∨⋯∨(mik∧mjt)⇔F
所以有
i
a
≠
j
b
,
a
∈
{
1
,
2
,
.
.
.
,
k
}
,
b
∈
{
1
,
2
,
…
,
t
}
i_a \ne j_b,\ a \in \{1, 2, ..., k\}, \ b \in \{1, 2, \dots, t\}
ia=jb, a∈{1,2,...,k}, b∈{1,2,…,t} ,故有
{
i
1
,
i
2
,
…
,
i
k
}
∩
{
j
1
,
j
2
,
…
,
j
t
}
=
∅
\{ i_1, i_2, \dots, i_k\} \cap \{j_1, j_2, \dots, j_t\} = \varnothing
{i1,i2,…,ik}∩{j1,j2,…,jt}=∅ 。
6.5 主范式的用途之一(逻辑推断)
由于通过一个命题公式的主范式,可以清楚地获知该命题公式为真和为假的赋值,因此利用命题公式的主范式,可以解决一些逻辑推断问题。
例6 甲乙丙丁四人中仅有两人代表单位参加了市里组织的象棋比赛,关于选择了谁参加了比赛,有如下四种正确的说法:
(a)甲和乙两人中只有一人参加;
(b)若丙参加了,则丁一定参加;
(c)乙和丁两人中至多参加一人;
(d)若丁不参加,则甲也不参加。
请推断哪两个人参加了这次比赛。
解答:设
A
A
A:甲参加了比赛,
B
B
B:乙参加了比赛,
C
C
C:丙参加了比赛,
D
D
D:丁参加了比赛。将上述命题符号化为:
(a)
A
⊕
B
⇔
(
¬
A
∧
B
)
∨
(
A
∧
¬
B
)
A \oplus B \Leftrightarrow (\lnot A \land B) \lor (A \land \lnot B)
A⊕B⇔(¬A∧B)∨(A∧¬B)
(b)
C
→
D
C \to D
C→D
(c)
¬
(
B
∧
D
)
\lnot (B \land D)
¬(B∧D)
(d)
¬
D
→
¬
A
\lnot D \to \lnot A
¬D→¬A
将命题公式
(
(
¬
A
∧
B
)
∨
(
A
∧
¬
B
)
)
∧
(
C
→
D
)
∧
¬
(
B
∧
D
)
∧
(
¬
D
→
¬
A
)
((\lnot A \land B) \lor (A \land \lnot B)) \land (C \to D) \land \lnot (B \land D) \land (\lnot D \to \lnot A)
((¬A∧B)∨(A∧¬B))∧(C→D)∧¬(B∧D)∧(¬D→¬A) 等价变换为主析取范式:
(
A
∧
¬
B
∧
¬
C
∧
D
)
∨
(
A
∧
¬
B
∧
C
∧
D
)
∨
(
¬
A
∧
B
∧
¬
C
∧
¬
D
)
(A \land \lnot B \land \lnot C \land D) \lor (A \land \lnot B \land C \land D) \lor (\lnot A \land B \land \lnot C \land \lnot D)
(A∧¬B∧¬C∧D)∨(A∧¬B∧C∧D)∨(¬A∧B∧¬C∧¬D) 。根据题意,有且仅有两人参加了比赛,可知只能是
(
A
∧
¬
B
∧
¬
C
∧
D
)
(A \land \lnot B \land \lnot C \land D)
(A∧¬B∧¬C∧D) 为
T
T
T ,即甲和丁参加了此次比赛。