Engineering Tools for AI

Informatik-Referenz

Leitfaden zu logischen Operatoren

Verstehen Sie AND, OR, NOT, XOR, NAND, NOR und verwandte Operatoren mit Wahrheitstabellen, boolescher Algebra, digitalen Schaltungen, Programmierung und AI Fragebeispielen.

Grundlogik

NOT

Notation
¬A, A'
Programmierung
Schaltung
Inverter gate

Beispiel

Reverses a truth value.

If A means logged in, ¬A means not logged in.

Wahrheitstabelle

AOut
01
10

Grundlogik

AND

Notation
A·B, AB
Programmierung
Schaltung
AND gate

Beispiel

True only when every input is true.

isLoggedIn && hasPermission

Wahrheitstabelle

ABOut
000
010
100
111

Grundlogik

OR

Notation
A+B
Programmierung
Schaltung
OR gate

Beispiel

True when at least one input is true.

isAdmin || isOwner

Wahrheitstabelle

ABOut
000
011
101
111

Abgeleitete Operatoren

XOR

Notation
A⊕B
Programmierung
Schaltung
XOR gate

Beispiel

True when the inputs are different.

Half adder sum = A XOR B.

Wahrheitstabelle

ABOut
000
011
101
110

Abgeleitete Operatoren

NAND

Notation
¬(A·B)
Programmierung
Schaltung
NAND gate

Beispiel

The negation of AND. NAND gates can build any Boolean circuit.

A NAND B = NOT (A AND B).

Wahrheitstabelle

ABOut
001
011
101
110

Abgeleitete Operatoren

NOR

Notation
¬(A+B)
Programmierung
Schaltung
NOR gate

Beispiel

The negation of OR. NOR is also functionally complete.

A NOR B is true only when both inputs are false.

Wahrheitstabelle

ABOut
001
010
100
110

Abgeleitete Operatoren

XNOR

Notation
¬(A⊕B)
Programmierung
Schaltung
XNOR gate

Beispiel

True when the inputs are the same.

A XNOR B behaves like equality for Boolean values.

Wahrheitstabelle

ABOut
001
010
100
111

Bitweise Operatoren

Bitwise AND

Notation
bit mask
Programmierung
Schaltung
Per-bit AND operation

Beispiel

Applies AND to each bit position. It is different from logical &&.

0101 & 0011 = 0001

Programmierung

Short-circuit evaluation

Notation
evaluation rule
Programmierung
Schaltung
Programming evaluation behavior

Beispiel

The second expression may not run if the first expression already determines the result.

user && user.name

Gesetze der booleschen Algebra

Identity laws

A ∧ 1 = A, A ∨ 0 = A

Combining with the neutral truth value leaves A unchanged.

Domination laws

A ∧ 0 = 0, A ∨ 1 = 1

One fixed input can determine the entire result.

Complement laws

A ∧ ¬A = 0, A ∨ ¬A = 1

A statement and its negation cannot both be true, but at least one is true.

De Morgan's laws

¬(A ∧ B) = ¬A ∨ ¬B, ¬(A ∨ B) = ¬A ∧ ¬B

Moves a negation across AND or OR while switching the operator.

Absorption laws

A ∨ (A ∧ B) = A, A ∧ (A ∨ B) = A

A repeated condition can absorb a more specific condition.