3.7. Reducing Your Boolean Logic
Problem
Many times a Boolean equation quickly becomes large, complex, and even unmanageable. You need a way to manage this complexity while at the same time verifying that your logic works as designed.
Solution
To fix this situation, try applying the theorems shown in Table 3-1 to minimize these types of equations.
Table 3-1. Boolean theorems
Theorem ID | Theorem definition |
|---|---|
T0 |
|
TI |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
T12 |
|
T13 |
|
T14 |
|
T15 |
|
T16 |
|
T17 |
|
T18 |
|
T19 |
|
T20 |
|
T21 |
|
T22 |
|
T23 |
|
T24 |
|
In Table 3-1, assume that w, x, y, and z are all variables of type bool. The theorem IDs allow easy identification of which theorems are being used in the Boolean equations that are being minimized in the Discussion section.
Discussion
Simplifying your Boolean logic will benefit your code by making it less cluttered and making its logic clearer and more readily understood. This simplification ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access