empros gmbh - process & information management services
1009-chatExperience is the hardest kind of teacher.
It gives you the test first and the lesson afterward.

-Susan Ruth

DeMorgan-Theorem

Heuristik

Vereinfache komplexe logische Ausdrücke mit Hilfe des DeMorgan-Theorems.

Erklärung

Die Anhäufung von Negationen erschwert die Verständlichkeit von logischen Ausdrücken in einem Programm. Daher lohnt es sich, Boolesche Ausdrücke positiv zu formulieren. Hierbei hilft uns das DeMorgan Theorem bei den logischen Operatoren or und and sowie zwei Operanden, indem wir jeden Operanden negieren, or und and gegeneinander vertauschen und den gesamten Ausdruck negieren. Die folgende Tabelle fasst die möglichen Kombinationen zusammen (Quelle: Code Complete, Kapitel 17):

Ursprünglicher Ausdruck
Gleichwertiger Ausdruck
not A and not B not (A or B)
not A and B not (A or not B)
A and not B not (not A or B)
A and B not (not A or not B)
not A or not B not (A and B)
not A or B not (A and not B)
A or not B not (not A and B)
A or B not (not A and not B)