基础逻辑
NOT
- 标记
- ¬A, A'
- 编程
- 电路
- Inverter gate
示例
Reverses a truth value.
If A means logged in, ¬A means not logged in.
真值表
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
计算机科学学习资料
整理 AND、OR、NOT、XOR、NAND、NOR 等逻辑运算,并搭配真值表、布尔代数、数字电路、编程与 AI 提问示例。
基础逻辑
Reverses a truth value.
If A means logged in, ¬A means not logged in.
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
基础逻辑
True only when every input is true.
isLoggedIn && hasPermission
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
基础逻辑
True when at least one input is true.
isAdmin || isOwner
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
派生运算
True when the inputs are different.
Half adder sum = A XOR B.
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
派生运算
The negation of AND. NAND gates can build any Boolean circuit.
A NAND B = NOT (A AND B).
| A | B | Out |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
派生运算
The negation of OR. NOR is also functionally complete.
A NOR B is true only when both inputs are false.
| A | B | Out |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
派生运算
True when the inputs are the same.
A XNOR B behaves like equality for Boolean values.
| A | B | Out |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
位运算
Applies AND to each bit position. It is different from logical &&.
0101 & 0011 = 0001
编程
The second expression may not run if the first expression already determines the result.
user && user.name
A ∧ 1 = A, A ∨ 0 = ACombining with the neutral truth value leaves A unchanged.
A ∧ 0 = 0, A ∨ 1 = 1One fixed input can determine the entire result.
A ∧ ¬A = 0, A ∨ ¬A = 1A statement and its negation cannot both be true, but at least one is true.
¬(A ∧ B) = ¬A ∨ ¬B, ¬(A ∨ B) = ¬A ∧ ¬BMoves a negation across AND or OR while switching the operator.
A ∨ (A ∧ B) = A, A ∧ (A ∨ B) = AA repeated condition can absorb a more specific condition.