逻辑运算符
在形式逻辑中,逻辑运算符或逻辑联结词把语句连接成更复杂的复杂语句。例如,假设有两个逻辑命题,分别是“正在下雨”和“我在屋里”,我们可以将它们组成复杂命题“正在下雨,并且我在屋里”或“没有正在下雨”或“如果正在下雨,那么我在屋里”。一个将两个语句组成的新的语句或命题叫做复合语句或复合命题。又称逻辑操作符(Logical Operators)。
基本運算符
基本的操作符有:“非”(¬)、“与”(∧)、“或”(∨)、“条件”(→)以及“双条件”(↔)。“非”是一个一元操作符,它只操作一项(¬ P)。剩下的是二元操作符,操作两项来组成复杂语句(P ∧ Q, P ∨ Q, P → Q, P ↔ Q)。
注意,符号“与”(∧)和交集(∩),“或”(∨)和并集(∪)的相似性。这不是巧合:交集的定义使用“与”,并集的定义是用“或”。
这些连接符的真值表:
P |
Q |
¬P |
P ∧ Q |
P ∨ Q |
P → Q |
P ↔ Q |
T |
T |
F |
T |
T |
T |
T |
T |
F |
F |
F |
T |
F |
F |
F |
T |
T |
F |
T |
T |
F |
F |
F |
T |
F |
F |
T |
T |
为了减少需要的括号的数量,有以下的优先规则:¬高于∧,∧高于∨,∨高于→。例如,P ∨ Q ∧ ¬ R → S是 (P ∨ (Q ∧ (¬ R)) → S的简便写法。
二元邏輯聯結詞表
下面是在輸入P和Q上的16個二元布林函數。
永假 |
符號 |
等價公式 |
真值表 |
文氏圖 |
⊥ {\displaystyle \bot } ⊥{\displaystyle \bot }⊥ |
P ∧ {\displaystyle \wedge } ∧{\displaystyle \wedge }∧ ¬P |
|
|
|
永真 |
符號 |
等價公式 |
真值表 |
文氏圖 |
⊤ {\displaystyle \top } ⊤{\displaystyle \top }⊤ |
P ∨ {\displaystyle \vee } ∨{\displaystyle \vee }∨ ¬P |
|
|
|
合取 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ∧ {\displaystyle \wedge } ∧{\displaystyle \wedge }∧ Q P & Q P · Q P AND Q |
P ↛ {\displaystyle \not \rightarrow } ↛{\displaystyle \not \rightarrow }→¬Q ¬P ↚ {\displaystyle \not \leftarrow } ↚{\displaystyle \not \leftarrow }← Q ¬P ↓ {\displaystyle \downarrow } ↓{\displaystyle \downarrow }↓ ¬Q |
|
|
|
與非 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ↑ Q P | Q P NAND Q |
P → ¬Q ¬P ← Q ¬P ∨ ¬Q |
|
|
|
非蘊涵 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ↛ {\displaystyle \not \rightarrow } ↛{\displaystyle \not \rightarrow }→ Q P ⊅ {\displaystyle \not \supset } ⊅{\displaystyle \not \supset }⊃ Q |
P & ¬Q ¬P ↓ Q ¬P ↚ {\displaystyle \not \leftarrow } ↚{\displaystyle \not \leftarrow }← ¬Q |
|
|
|
蘊涵 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P → Q P ⊃ {\displaystyle \supset } ⊃{\displaystyle \supset }⊃ Q |
P ↑ ¬Q ¬P ∨ Q ¬P ← ¬Q |
|
|
|
|
|
反非蘊涵 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ↚ {\displaystyle \not \leftarrow } ↚{\displaystyle \not \leftarrow }← Q P ⊄ {\displaystyle \not \subset } ⊄{\displaystyle \not \subset }⊂ Q |
P ↓ ¬Q ¬P & Q ¬P ↛ {\displaystyle \not \rightarrow } ↛{\displaystyle \not \rightarrow }→ ¬Q |
|
|
|
反蘊涵 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ← {\displaystyle \leftarrow } ←{\displaystyle \leftarrow }← Q P ⊂ {\displaystyle \subset } ⊂{\displaystyle \subset }⊂ Q |
P ∨ ¬Q ¬P ↑ Q ¬P → ¬Q |
|
|
|
|
|
異或 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ↮ {\displaystyle \not \leftrightarrow } ↮{\displaystyle \not \leftrightarrow }↔ Q P ≢ {\displaystyle \not \equiv } ≢{\displaystyle \not \equiv }≡ Q P ⊕ {\displaystyle \oplus } ⊕{\displaystyle \oplus }⊕ Q P XOR Q |
P ↔ ¬Q ¬P ↔ Q ¬P ↮ {\displaystyle \not \leftrightarrow } ↮{\displaystyle \not \leftrightarrow }↔ ¬Q |
|
|
|
雙條件 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ↔ Q P ≡ Q P XNOR Q P IFF Q |
P ↮ {\displaystyle \not \leftrightarrow } ↮{\displaystyle \not \leftrightarrow }↔ ¬Q ¬P ↮ {\displaystyle \not \leftrightarrow } ↮{\displaystyle \not \leftrightarrow }↔ Q ¬P ↔ ¬Q |
|
|
|
析取 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ∨ Q P ∨ Q P OR Q |
P ← {\displaystyle \leftarrow } ←{\displaystyle \leftarrow }← ¬Q ¬P → Q ¬P ↑ ¬Q |
|
|
|
或非 |
符號 |
等價公式 |
真值表 |
文氏圖 |
P ↓ Q P NOR Q |
P ↚ {\displaystyle \not \leftarrow } ↚{\displaystyle \not \leftarrow }← ¬Q ¬P ↛ {\displaystyle \not \rightarrow } ↛{\displaystyle \not \rightarrow }→ Q ¬P ∧ ¬Q |
|
|
|