命题逻辑 (Propositional Logic)
命题与非命题 (Propositions vs Non-Propositions)
-
命题 (proposition):要么真要么假的陈述句
例子:- $\sqrt{3}$ 是无理数
- $1+1=5$
- “凯撒十岁生日早餐吃了两个鸡蛋”
-
非命题:缺少信息或含有模糊词,不能判断真伪
例子:- $2+2$ (不完整)
- $x^2+3x=5$ (未说明 $x$)
- “施瓦辛格经常吃西兰花”(“经常”模糊)
- “亨利八世不受欢迎”(“不受欢迎”模糊)
逻辑连接词 (Logical Connectives)
- 合取 (Conjunction):$P \land Q$
- 仅当 $P,Q$ 同真时为真
- 析取 (Disjunction):$P \lor Q$
- 至少一真时为真
- 否定 (Negation):$\lnot P$
- $P$ 为假时为真
排中律 (Law of the Excluded Middle)
- $P \lor \lnot P$ 恒真(永真式 tautology)
- $P \land \lnot P$ 恒假(矛盾 contradiction)
真值表 (Truth Tables)
合取 (AND)
P | Q | $P \land Q$ |
---|---|---|
T | T | T |
T | F | F |
F | T | F |
F | F | F |
否定 (NOT)
P | $\lnot P$ |
---|---|
T | F |
F | T |
蕴含 (Implication)
- 定义:$P \Rightarrow Q$ (若 P,则 Q)
- 真值:仅当 $P$ 真而 $Q$ 假时为假;其余情况为真
- 等价式:
$(P \Rightarrow Q) \equiv (\lnot P \lor Q)$
例子:
- “若你在雨中站着,则你会被淋湿”
- “若猪会飞,则马会读书” (前件假 → 命题 空真 vacuously true)
常见同义表述
- “if P then Q”
- “Q if P”
- “P only if Q”
- “P is sufficient for Q”
- “Q is necessary for P”
- “Q unless not P”
双向蕴含 (Biconditional)
- $P \Leftrightarrow Q$ (“P 当且仅当 Q”)
- 当 $P,Q$ 真值相同(同真或同假)时为真
逆命题与逆否命题
- 逆否 (Contrapositive):$\lnot Q \Rightarrow \lnot P$,与原命题 等价
- 逆命题 (Converse):$Q \Rightarrow P$,一般 不等价
对照表
类型 | 形式 | 与 $P \Rightarrow Q$ 关系 |
---|---|---|
原命题 | $P \Rightarrow Q$ | — |
逆否 | $\lnot Q \Rightarrow \lnot P$ | 等价 |
逆命 | $Q \Rightarrow P$ | 不等价 |
量词 (Quantifiers)
基本概念
- 数学中的陈述不仅仅是简单命题,还常常涉及 大量对象。
- 谓词 (predicate):带有变量的陈述,代入具体值后才成为命题。
- 例子:$P(n): n^2+n+41 \text{ 是素数}$
- $n=1$ → $43$ 是素数 → 真
- $n=41$ → $41^2+41+41 = 41 \times 43$ → 假
- 例子:$P(n): n^2+n+41 \text{ 是素数}$
两种量词
-
全称量词 (Universal Quantifier):$\forall$
- “对所有 (for all)”
- 例子:$(\forall n \in \mathbb{N})(n^2+n+41 \text{ 是素数})$
-
存在量词 (Existential Quantifier):$\exists$
- “存在 (there exists)”
- 例子:$(\exists x \in U_{\text{mammals}})(x \text{ lays eggs})$
有限与无限
-
有限集:
- $U={1,2,3,4}$
- $(\exists x \in U)P(x) \equiv P(1)\lor P(2)\lor P(3)\lor P(4)$
- $(\forall x \in U)P(x) \equiv P(1)\land P(2)\land P(3)\land P(4)$
-
无限集:
- 如自然数 $\mathbb{N}$,无法展开,只能使用量词表示
多重量词 (Multiple Quantifiers)
- 命题可同时含有多个量词
- 量词不交换(次序不同 → 语义不同)
例子 1:地铁故事
- $(\forall t \in T)(\exists p \in P)(p \text{ 在时间 } t \text{ 被捅})$
→ 每次乘地铁,都会有人被捅(可能不同人) - $(\exists p \in P)(\forall t \in T)(p \text{ 每次都被捅})$
→ 存在某个倒霉鬼,每次都被捅
例子 2:整数大小
4. $(\forall x \in \mathbb{Z})(\exists y \in \mathbb{Z})(x < y)$
→ 对任意整数,总能找到更大的数 (真)
5. $(\exists y \in \mathbb{Z})(\forall x \in \mathbb{Z})(x < y)$
→ 存在最大整数 (假)
否定 (Much Ado About Negation)
基本定义
- 一个命题 $P$ 为假,意味着它的否定 $\lnot P$ 为真。
- 否定在逻辑推理和证明中非常重要。
德摩根律 (De Morgan’s Laws) —— 命题逻辑版
- $\lnot (P \land Q) \equiv (\lnot P \lor \lnot Q)$
- $\lnot (P \lor Q) \equiv (\lnot P \land \lnot Q)$
直观理解:
- “不是 (P 且 Q)” 等价于 “P 不成立或 Q 不成立”
- “不是 (P 或 Q)” 等价于 “P 不成立且 Q 不成立”
德摩根律 —— 量词版
- $\lnot (\forall x, P(x)) \equiv \exists x, \lnot P(x)$
- $\lnot (\exists x, P(x)) \equiv \forall x, \lnot P(x)$
例子:
- “不是所有整数都是奇数” → “存在一个整数不是奇数(即偶数)”
推进否定 (Negation Pushing)
- 否定可以逐步向内推进,遇到量词时翻转:
- $\forall \leftrightarrow \exists$
- 同时加上否定符号
例子:
“至少 / 至多 / 恰好” 的量词表达
-
至少三个满足 $P$ 的整数:
$\exists x \exists y \exists z (x \neq y \land y \neq z \land z \neq x \land P(x) \land P(y) \land P(z))$ -
至多三个满足 $P$ 的整数(写法一):
$\exists x \exists y \exists z \forall d (P(d) \Rightarrow (d=x \lor d=y \lor d=z))$ -
至多三个(写法二,等价形式):
$\forall x \forall y \forall v \forall z \Big( \text{四者两两不同} \Rightarrow \lnot(P(x)\land P(y)\land P(v)\land P(z)) \Big)$ -
恰好三个:
“至少三个” $\land$ “至多三个”