3.11 NOT statement. Looking for a clearer explanation


#1

I'm having trouble understanding why this following code block is false.

"# boolean_2 = !true && !true
boolean_2 = false"

With my knowledge a false && false statement should equal true. Is there a clearer explanation to this other than thats the way it is? Thanks in advance!


#2

Consider...

A = true
B = true

 A && B     # true and true   =>  true
!A && B     # false and true  => false
 A && !B    # true and false  => false
!A && !B    # false and false => false

An AND expression may only return true if all operands in the expression evaluate to true. When we NOT an expression, we toggle the Boolean evaluation of that expression.

!true == false
!false == true

Now consider that A and B are unchanged from above.

!(A && B)     # NOT (true && true)   => NOT true        => false

Brackets are evaluated first, then NOT, which differs slightly from above,

!A && !B      # NOT true && NOT true => false && false  => false

As we can see, false && false is never true.


#3

Supplemental

Let's consider AND as being multiplicative, A && B => A * B, and let the following table illustrate true as 1, and false as 0:

   A    0    1
B  ------------
0  |    0    0
1  |    0    1

#4

Ah yes, I see. Thank you so much for your very detailed explanation.