
Simplifying Boolean Expressions and Conditionals - userbinator
http://cs111.wellesley.edu/~cs111/archive/cs111_spring00/public_html/lectures/boolean-simplification.html
======
gopalv
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)

------
jancsika
The table shows that

(! boolExp1) || (! boolExp2)

is equivalent to the simplified version:

! (boolExp1 && boolExp2)

I read the first one as, "Either of these bools are false." and the second as,
"Not (true) that both of these bools are true." Thus in a conditional I more
quickly comprehend the first.

~~~
userbinator
That's basic DeMorgan. I think it really depends on the context, i.e. how
boolExp1 and boolExp2 are named. Too many ! can sometimes make the meaning
hard to comprehend.

