互斥析取
| 互斥析取 | |
|---|---|
| 术语名称 | 互斥析取 |
| 英语名称 | exclusive disjunction |
| 别名 | 逻辑异或, logical XOR, 排斥或, 不可兼或, exclusive or |
互斥析取(exclusive disjunction)是二元逻辑联结词,表示“两个命题中恰好一个为真”所对应的命题。 对应自然语言中或的排它性用法。
通常意义上的“或”可能指“相容或”(析取)或“排斥或”(互斥析取)。
互斥析取不是五个常用逻辑联结词之一,但其对应的逻辑异或和按位异或在计算机科学等领域有大量应用。
定义
| 互斥析取 | |
|---|---|
| 运算名称 | 互斥析取 |
| 运算符号 | [math]\displaystyle{ \nleftrightarrow }[/math],[math]\displaystyle{ \oplus }[/math],[math]\displaystyle{ \veebar }[/math] |
| Latex | \nleftrightarrow, \oplus, \veebar
|
| 运算对象 | 命题公式 |
| 运算元数 | 2 |
| 运算结果 | 命题公式 |
| 结构 | 布尔代数
|
对命题 [math]\displaystyle{ P }[/math] 、 [math]\displaystyle{ Q }[/math] ,记命题 [math]\displaystyle{ R }[/math] 满足:
- 当 [math]\displaystyle{ P }[/math] 为真,同时 [math]\displaystyle{ Q }[/math] 为假时,命题 [math]\displaystyle{ R }[/math] 为真;
- 当 [math]\displaystyle{ P }[/math] 为假,同时 [math]\displaystyle{ Q }[/math] 为真时,命题 [math]\displaystyle{ R }[/math] 为真;
- 当 [math]\displaystyle{ P }[/math] 为真,同时 [math]\displaystyle{ Q }[/math] 也为真时,命题 [math]\displaystyle{ R }[/math] 为假;
- 当 [math]\displaystyle{ P }[/math] 为假,同时 [math]\displaystyle{ Q }[/math] 也为假时,命题 [math]\displaystyle{ R }[/math] 为假。
称这样的命题 [math]\displaystyle{ R }[/math] 为命题 [math]\displaystyle{ P }[/math] 与命题 [math]\displaystyle{ Q }[/math] 的互斥析取(exclusive disjunction),记作 [math]\displaystyle{ P \nleftrightarrow Q }[/math] 、 [math]\displaystyle{ P \oplus Q }[/math] 或 [math]\displaystyle{ P \veebar Q }[/math] ,读作[math]\displaystyle{ P }[/math] 异或 [math]\displaystyle{ Q }[/math]([math]\displaystyle{ P }[/math] xor [math]\displaystyle{ Q }[/math]) 或 [math]\displaystyle{ P }[/math] 互斥析取 [math]\displaystyle{ Q }[/math]。
| ↮ | |
|---|---|
| 字符 | ↮ |
| Unicode码位 | U+21AE Left Right Arrow with Stroke
|
| Latex命令序列 | \nleftrightarrow
|
| ⊕ | |
|---|---|
| 字符 | ⊕ |
| Unicode码位 | U+2295 Circled Plus
|
| Latex命令序列 | \oplus
|
| ⊻ | |
|---|---|
| 字符 | ⊻ |
| Unicode码位 | U+22BB XOR
|
| Latex命令序列 | \veebar
|
互斥析取不像五个常用逻辑联结词有约定俗成的规则,这三个符号都有出现情况。中文语境中一般使用 [math]\displaystyle{ \oplus }[/math] 。 互斥析取的其他记号有 [math]\displaystyle{ + }[/math] (因为可以看作模 2 剩余类群加法)和 [math]\displaystyle{ \dot\vee }[/math] 。
真值表
| [math]\displaystyle{ p }[/math] | [math]\displaystyle{ q }[/math] | [math]\displaystyle{ p \nleftrightarrow q }[/math] |
|---|---|---|
| T | T | F |
| T | F | T |
| F | T | T |
| F | F | F |
性质
- 等价表示
- 是等价的否定:对任意命题 [math]\displaystyle{ P }[/math] 和 [math]\displaystyle{ Q }[/math] , [math]\displaystyle{ P\nleftrightarrow Q = \lnot(P\leftrightarrow Q) }[/math] 。
- 表达为否定、合取、析取的组合:对任意命题 [math]\displaystyle{ P }[/math] 和 [math]\displaystyle{ Q }[/math] , [math]\displaystyle{ P\nleftrightarrow Q = (P \lor Q) \land \lnot(P \land Q) = (P\land \lnot Q) \lor (\lnot P \land Q) }[/math] 。
- 运算性质
- 结合律:对任意命题 [math]\displaystyle{ P }[/math] 、 [math]\displaystyle{ Q }[/math] 和 [math]\displaystyle{ R }[/math],有 [math]\displaystyle{ (P \nleftrightarrow Q) \nleftrightarrow R = P \nleftrightarrow (Q \nleftrightarrow R) }[/math] 。
- 交换律:对任意命题 [math]\displaystyle{ P }[/math] 和 [math]\displaystyle{ Q }[/math] ,有 [math]\displaystyle{ P \nleftrightarrow Q = Q \nleftrightarrow P }[/math] 。
- 特殊值
- [math]\displaystyle{ P \nleftrightarrow \mathrm{F} = P }[/math] 。
- [math]\displaystyle{ P \nleftrightarrow \mathrm{T} = \lnot P }[/math] 。
- 每个元素都是二阶元、是自身的逆元:对任意命题 [math]\displaystyle{ P }[/math] , [math]\displaystyle{ P\nleftrightarrow P=\mathrm{F} }[/math] 。
- 是自身的逆运算:对于任意命题 [math]\displaystyle{ P }[/math] 和 [math]\displaystyle{ Q }[/math] ,有 [math]\displaystyle{ (P \nleftrightarrow Q) \nleftrightarrow Q = P }[/math] 。
不同逻辑系统中的互斥析取
以上为经典逻辑中的互斥析取:是真值函数的,完全由真值表定义。
- 多值逻辑、模糊逻辑中,真值的取值可能性更多,互斥析取可能有更复杂的定义方式,但通常保持“两个值不同时为真”的核心概念。
自然语言中,“或”等都可能表达互斥析取的逻辑关系,且语境中可能限制两个不能同时选择。 分句间常见的表示互斥析取的连词包括“要么……要么……”“或者……或者……”“不是……就是……”等,这几个说法一般都暗示两个选项不能同时选择。
多元互斥析取
对命题 [math]\displaystyle{ P_1, P_2, \dots , P_n }[/math] ,由“这些命题中奇数个为真”所对应的命题,记作 [math]\displaystyle{ P_1 \oplus P_2 \oplus \dots \oplus P_n }[/math] 。也记作 [math]\displaystyle{ \bigoplus_{i=1}^n P_i = P_1 \oplus P_2 \oplus \dots \oplus P_n }[/math] 。
在此基础上, 1 个命题的互斥析取定义为命题自身, 0 个命题的互斥析取定义为假。
多个命题的互斥析取也可以等价地定义为这些命题两两进行互斥析取,由于满足结合律、交换律而顺序无关,也不需要区分二元运算和多元运算。这是基于结合律成立产生定义。
多元互斥析取通常只能定义在有限个命题上。
注: [math]\displaystyle{ \nleftrightarrow }[/math] 记号虽然在二元运算上更标准,但由于连续使用时 [math]\displaystyle{ \nleftrightarrow }[/math] 不如 [math]\displaystyle{ \oplus }[/math] 美观,且不便于使用大记号,多元运算中一般使用 [math]\displaystyle{ \oplus }[/math] 。
多元严格互斥
多元的排斥或,定义为“这些命题中恰有一个为真”,这种定义在逻辑学中较少见,没有约定俗成的名称指代或符号表示。
| 逻辑联结词 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 零元 | ||||||||||||||||||
| 真值表 | [math]\displaystyle{ \bot }[/math] | [math]\displaystyle{ \top }[/math] | ||||||||||||||||
| T | F | |||||||||||||||||
| 名称 | 真 [math]\displaystyle{ \top }[/math] | 假 [math]\displaystyle{ \bot }[/math] | ||||||||||||||||
| 二进制编号 | 0 | 1 | ||||||||||||||||
| 编号 | 0 | 1 | ||||||||||||||||
| 一元 | ||||||||||||||||||
| 真值表 | [math]\displaystyle{ p }[/math] | [math]\displaystyle{ \bot }[/math] | [math]\displaystyle{ \lnot p }[/math] | [math]\displaystyle{ p }[/math] | [math]\displaystyle{ \top }[/math] | |||||||||||||
| T | F | T | ||||||||||||||||
| F | F | T | F | T | ||||||||||||||
| 名称 | 假 [math]\displaystyle{ \bot }[/math] | 否定(非) [math]\displaystyle{ \lnot }[/math] | (恒等映射 [math]\displaystyle{ \mathrm{id} }[/math]) | 真 [math]\displaystyle{ \top }[/math] | ||||||||||||||
| 缩写 | - | NOT | - | - | ||||||||||||||
| 二进制编号 | 00 | 01 | 10 | 11 | ||||||||||||||
| 编号 | 0 | 1 | 2 | 3 | ||||||||||||||
| 二元 | ||||||||||||||||||
| 真值表 | [math]\displaystyle{ p }[/math] | [math]\displaystyle{ q }[/math] | [math]\displaystyle{ \bot }[/math] | [math]\displaystyle{ p \bar{\vee} q }[/math] [math]\displaystyle{ p \downarrow q }[/math] |
[math]\displaystyle{ p \nleftarrow q }[/math] | [math]\displaystyle{ \lnot p }[/math] | [math]\displaystyle{ p \nrightarrow q }[/math] | [math]\displaystyle{ \lnot q }[/math] | [math]\displaystyle{ p \oplus q }[/math] [math]\displaystyle{ p \nleftrightarrow q }[/math] |
[math]\displaystyle{ p \barwedge q }[/math] [math]\displaystyle{ p \uparrow q }[/math] |
[math]\displaystyle{ p \land q }[/math] | [math]\displaystyle{ p \leftrightarrow q }[/math] | [math]\displaystyle{ q }[/math] | [math]\displaystyle{ p \rightarrow q }[/math] | [math]\displaystyle{ p }[/math] | [math]\displaystyle{ p \leftarrow q }[/math] | [math]\displaystyle{ p \lor q }[/math] | [math]\displaystyle{ \top }[/math] |
| T | T | F | T | |||||||||||||||
| F | F | T | F | T | ||||||||||||||
| F | T | F | T | F | T | F | T | F | T | |||||||||
| F | F | T | F | T | F | T | F | T | F | T | F | T | F | T | F | T | ||
| 名称 | 假 [math]\displaystyle{ \bot }[/math] |
或非 [math]\displaystyle{ \downarrow }[/math]/[math]\displaystyle{ \bar{\vee} }[/math] |
- | 否定 非 [math]\displaystyle{ \lnot }[/math] |
- | 否定 非 [math]\displaystyle{ \lnot }[/math] |
互斥析取 异或 [math]\displaystyle{ \oplus }[/math]/[math]\displaystyle{ \nleftrightarrow }[/math]/[math]\displaystyle{ \veebar }[/math] |
与非 [math]\displaystyle{ \uparrow }[/math]/[math]\displaystyle{ \barwedge }[/math] |
合取 且/与 [math]\displaystyle{ \land }[/math] |
等价 当且仅当 [math]\displaystyle{ \leftrightarrow }[/math] |
投影映射 [math]\displaystyle{ \mathrm{proj}_2 }[/math] |
蕴涵 推出 [math]\displaystyle{ \rightarrow }[/math] |
投影映射 [math]\displaystyle{ \mathrm{proj}_1 }[/math] |
- | 析取 或 [math]\displaystyle{ \lor }[/math] |
真 [math]\displaystyle{ \top }[/math] | ||
| 缩写 | - | NOR | - | NOT | NIMPLY | NOT | XOR | NAND | AND | XNOR EQV |
- | IMPLY | - | - | OR | - | ||
| 二进制编号 | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 | ||
| 编号 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ||
琐事
名称
“异或”的名字应当如下理解: 它首先是“或”的一种。 日常用语的“或”有两种:至少一个、恰好一个;前者在术语中更常用,直接称为“或”,于是后者只好称为“异或”。[1] 一说其含义为表达“相异”的“或”,这种说法虽然更常见,但无法解释仍保留“或”字而不是与主要联结词一样被缩减到一个字。
异或经常缩写为“XOR”,是 exclusive or 的缩写,读 [̩ɛksˈɔː] 或 [ksɔː] 。也曾有过 EOR 和 EXOR 的写法,但现在很少见。[2]