离散数学

数理逻辑

命题的分类

合式公式

命题演算的合式公式(well-formed formula)规定为

列真值表的方式

分别列出每个合式公式的真值:

PP QQ PQP \lor Q P(PQ)P \land (P \lor Q)
T T T T
T F T T
F T T F
F F F F

常用命题基本公式

例题:

  1. 证明(PQ)(P¬Q)    P.(P \land Q) \lor (P \land \lnot Q) \iff P.
    证:

(PQ)(P¬Q)P(Q¬Q)PTP\begin{align*} (P \land Q) \lor (P \land \lnot Q) &\equiv P\land(Q \lor \lnot Q)\\ &\equiv P \land T\\ &\equiv P\\ \end{align*}

  1. 证明 P(PQ)Q    TP \land (P \to Q) \to Q \iff T.
    证:

P(PQ)QP(¬PQ)QF(PQ)QPQQ¬(PQ)Q¬P¬QQ¬PTT\begin{align*} P \land (P \to Q) \to Q &\equiv P \land (\lnot P \lor Q) \to Q\\ &\equiv F \lor (P \land Q) \to Q\\ &\equiv P \land Q \to Q\\ &\equiv \lnot (P \land Q) \lor Q\\ &\equiv \lnot P \lor \lnot Q \lor Q\\ &\equiv \lnot P \lor T\\ &\equiv T\\ \end{align*}

连接词的全功能集

对偶与范式


对偶

将命题 AA 中的 \lor 换成 \land ,将 \land 换成 \lor,常量 TT 换成 FFFF 换成 TT,得到的命题 AA^* 称为该命题的对偶。显然有 (A)=A(A^*)^* = A

例如:¬(PQ)(P¬(Q¬S))\lnot(P∨Q)∧(P∨\lnot(Q∧\lnot S)) 的对偶是 ¬(PQ)(P¬(Q¬S))\lnot(P∧Q)∨(P∧\lnot(Q∨\lnot S))

定理

¬A(P1,,...,Pn)    A(¬P1,...,¬Pn)\lnot A( P1,,...,Pn ) \iff A^*(\lnot P1, ..., \lnot Pn)


范式

每个命题公式都有很多与之逻辑等价的公式,其中较为符合标准的称为“范式”。

定义:
一个命题公式称为析取范式,当且仅当它具有形式:

A1A2,An,(n1)A_1 \lor A_2 \lor …, \lor A_n, (n \geqslant 1)

其中 A1,A2,...,AnA_1,A_2,...,A_n 都是由文字(即命题常元、变元和它们的否定)所组成的合取式。

PQR,PQR,¬P,¬(PQ)RP∧Q∧R, P∨ Q ∨ R, \lnot P, \lnot (P∧Q) ∨R 都是析取范式。

定义: 一个命题公式称为合取范式,当且仅当它具有形式:

A1A2,An,(n1)A_1 \land A_2 \land …, \land A_n, (n \geqslant 1)

其中 A1,A2,...,AnA_1,A_2,...,A_n 都是由命题变元或其否定所组成的简单析取式

PQR,(PQ)R,¬PP ∨ Q ∨ R, (P∨ Q) ∧R, \lnot P都是合取范式,¬(PQ)R,P(QR)\lnot (P∨ Q) ∧R, P∨ ( Q∧R ) 不是合取范式。

任意命题公式均可通过等价演算化为合取或析取范式。

例:求 (P(QR))S(P \land (Q \to R)) \to S 的合取范式.

(P(QR))S¬(P(QR))S¬P¬(QR)S¬P¬(¬QR)S¬P(Q¬R)S¬P((QS)¬RS)(¬PQS)(¬P¬RS)\begin{align*} &(P \land (Q \to R)) \to S\\ \equiv& \lnot (P \land (Q \to R)) \lor S\\ \equiv& \lnot P \lor \lnot (Q \to R) \lor S\\ \equiv& \lnot P \lor \lnot (\lnot Q \lor R) \lor S\\ \equiv& \lnot P \lor (Q \land \lnot R) \lor S\\ \equiv& \lnot P \lor ((Q \lor S) \land \lnot R \lor S) \\ \equiv& (\lnot P \lor Q \lor S) \land (\lnot P \lor \lnot R \lor S)\\ \end{align*}

主范式

定义: 合取式 A1A2,AnA_1 \land A_2 \land …, \land A_n 称为变元组P1,P2,...,PnP_1,P_2,...,P_n 的一个小项,其中 AiA_iPiP_i 构成的文字。

定义: 对于给定的命题公式,如果有一个等价公式,它仅由小项的析取所组成,则该等价式称作原式的主析取范式

定义: 析取式 A1A2,AnA_1 \lor A_2 \lor …, \lor A_n 称为变元组P1,P2,...,PnP_1,P_2,...,P_n 的一个大项,其中 AiA_iPiP_i 构成的文字。

定义: 对于给定的命题公式,如果有一个等价公式,它仅由大项的合取所组成,则该等价式称作原式的主合取范式

定理: 煮稀饭式与煮盒饭式互补。每个命题公式都有唯一的煮稀饭式和煮盒饭式。

求煮稀饭式的方法:

1 真值表法

定理:在一个公式的真值表中,成真赋值对应的小项做析取,即为此公式的主析取范式.

例:求 PQP \to Q 的主析取范式.

PP QQ PQP \to Q 对应小项
TT TT TT PQP \land Q
TT FF FF P¬QP\land\lnot Q
FF TT TT ¬PQ\lnot P\land Q
FF FF TT ¬T¬Q\lnot T\land \lnot Q

PQ    (PQ)(¬PQ)(¬P¬Q)P→Q \iff (P\land Q) \lor (\lnot P \land Q) \lor (\lnot P \land \lnot Q)

2 推演法

  1. 将公式化归为析取范式。
  2. 去掉析取范式中永假的小项。
  3. 合并析取范式中重复的小项。
  4. 对合取项中未出现的变元 PP,以 P¬PP \lor \lnot P 加入, 然后用分配律展开.

例:求 P((PQ)¬(¬Q¬P))P→((P→Q)\land \lnot(\lnot Q \lor \lnot P ))的煮稀饭式。

P((PQ)¬(¬Q¬P))¬P((¬PQ)(QP))¬P((¬PQP)(QQP))¬P(PQ)(¬PQ¬Q)(PQ)(¬PQ)(¬P¬Q)(PQ)\begin{align*} &P→((P→Q)\land \lnot(\lnot Q \lor \lnot P )) \\ &\equiv \lnot P \lor ((\lnot P \lor Q) \land (Q \land P))\\ &\equiv \lnot P \lor ((\lnot P \land Q \land P) \lor (Q \land Q \land P))\\ &\equiv \lnot P \lor ( P\land Q)\\ &\equiv (\lnot P \land Q \lor \lnot Q) \lor (P \land Q)\\ &\equiv (\lnot P \land Q) \lor (\lnot P \land \lnot Q) \lor (P \land Q)\\ \end{align*}

求煮盒饭式的方法类似。


谓词演算的推理理论

ABABTA \Rightarrow B 即 A \to B \lrArr T 要证 CC 是一组前提 H1,H2,...,HnH_1, H_2, ... , H_n 的有效结论,需证:

H1H2...HnC是重言式H_1 \land H_2 \land ... \land H_n \to C 是重言式

例题1:证明(x)(H(x)M(x))H(s)M(s)(\exist x)(H(x) \to M(x))\land H(s) \Rightarrow M(s) (苏格拉底三段论).

(x)(H(x)M(x))PH(s)M(s)T1H(s)PM(s)T2,3,I\begin{align*} &(\exist x)(H(x) \to M(x)) &P\\ &H(s) \to M(s) &T1\\ &H(s) &P\\ &M(s) &T2,3,I\\ \end{align*}

例题2:证明 (x)(C(x)W(x)R(x))(x)(C(x)Q(x))(x)(Q(x)R(x))(\forall x)(C(x) \to W(x) \land R(x)) \land (\exist x)(C(x) \land Q(x)) \to (\exist x)(Q(x) \land R(x))

(1).(x)(C(x)Q(x))P(2).C(a)Q(a)T1,ES(3).C(a)T2,I1(4).Q(a)T2(5).(x)(C(x)W(x)R(x))P(6).C(a)W(a)R(a)T5,US(7).W(a)R(a)T3,6,I(8).R(a)T7,I(9).Q(a)R(a)T4,8,I(10).(x)(Q(x)R(x))T9,EG\begin{align*} &(1). (\exist x)(C(x) \land Q(x)) &P\\ &(2). C(a) \land Q(a) &T1, ES\\ &(3). C(a) &T2, I1\\ &(4). Q(a) &T2\\ &(5). (\forall x)(C(x) \to W(x) \land R(x)) &P\\ &(6). C(a) \to W(a) \land R(a) &T5, US\\ &(7). W(a) \land R(a) &T3,6,I\\ &(8). R(a) &T7, I\\ &(9). Q(a) \land R(a) &T4, 8, I\\ (&10). (\exist x) (Q(x) \land R(x)) &T9, EG\\ \end{align*}