逻辑异或
外观
| 逻辑异或 | |
|---|---|
| 术语名称 | 逻辑异或 |
| 英语名称 | logical XOR |
逻辑异或(logical XOR)指二值变量的一种运算,相当于命题真值间的互斥析取联结词。与模 2 剩余类环上的加法同构。
定义
| 逻辑异或 | |
|---|---|
| 运算名称 | 逻辑异或 |
| 运算符号 | [math]\displaystyle{ \oplus }[/math],[math]\displaystyle{ \veebar }[/math] |
| Latex | \oplus, \veebar
|
| 运算对象 | 二值变量 |
| 运算元数 | 2 |
| 运算结果 | 二值变量 |
| 定义域 | [math]\displaystyle{ \mathbb{B} \times \mathbb{B} }[/math] |
| 陪域 | [math]\displaystyle{ \mathbb{B} }[/math] |
对二值变量 [math]\displaystyle{ x, y \in \mathbb{B} = \{0,1\} }[/math] ,将二元运算 [math]\displaystyle{ (1,1)\mapsto 0; (0,1)\mapsto 1;(1,0)\mapsto 1;(0,0)\mapsto 0 }[/math] 称为逻辑异或(logical XOR)运算,记作 [math]\displaystyle{ x\oplus y }[/math] 。也有人记作 [math]\displaystyle{ x\veebar y }[/math] 。
也可以建模为 [math]\displaystyle{ \mathbf{F}_2 }[/math] 上的加法。
乘法表
| [math]\displaystyle{ \oplus }[/math] | T | F |
|---|---|---|
| T | F | T |
| F | T | F |
性质
运算性质:
多元逻辑异或
由于是一种符合结合律的运算,可以自然扩展到定义多元逻辑异或运算。
变体
三值逻辑异或
对三值逻辑变量,也存在对应逻辑异或的同名运算。
| [math]\displaystyle{ \oplus }[/math] | T | U | F |
|---|---|---|---|
| T | F | U | T |
| U | U | U | U |
| F | T | U | F |
由于三值逻辑变量存在不同语义的体系,其中[math]\displaystyle{ U\oplus U }[/math] 在不同体系下可能是 [math]\displaystyle{ U/F }[/math] 。
| 逻辑运算 | |||
|---|---|---|---|
| 逻辑非 | 逻辑与 | 逻辑或 | 逻辑异或 |