2 ms·
Over my CS education, the biggest logical leap I've made towards automating massive number of boolean operations came from using the normal forms as much as pos
by gopalv 9y ago
Over my CS education, the biggest logical leap I've made towards automating massive number of boolean operations came from using the normal forms as much as possible - conjuctive and disjunctive normal forms.
I personally prefer the DNF as my go-to thinking mode, but it can be very verbose if you print out with parenthesis, but it can be re-processed into what I draw up as a "tic-tac-toe" diagram (the official term is K-map[1]).
You can even compress a very large boolean condition tree into an integer form and just lookup this faster.
Once you start seeing these are integer bitset ranges/groups instead of branches, then you can work that backwards too - I've seen a super-optimizing compiler for network ACLs which takes (srchost, dsthost, port) as 42 booleans => 1 Allow/Deny, by compressing the Allow rules using a the datastructure as an intermediate step.
[1] - https://en.wikipedia.org/wiki/Karnaugh_map https://en.wikipedia.org/wiki/Karnaugh_map