One of my exam questions reads:
! ( ! ( a != b) && ( b > 7 ) )
The choices:
a) (a != b) || (b < 7)
b) (a != b) || (b <= 7)
c) (a == b) || (b <= 7)
d) (a != b) && (b <= 7)
e) (a == b) && (b > 7)
Initially, I thought it would be D. This is incorrect, and I realize why. I don't understand how the logical negation operator reverses && and greater than/less than. I believe I have narrowed it down to the first two. Is there any instance > would change to <= ?
Is there any instance > would change to <= ?
Answer: every time you negate it.
Consider x > 1. The negation of this is clearly x <= 1. If you simply negate it as x < 1 then neither case covers the x == 1 case.
That being said, the given boolean ! ( ! ( a != b) && ( b > 7 ) ) can be decomposed as follows:
Given:
! ( !(a != b) && (b > 7))
Negate a != b:
! ((a == b) && (b > 7))
Distribute the !:
!(a == b) || !(b > 7)
Negate a==b:
(a != b) || !(b > 7)
Negate b>7:
(a != b) || (b <= 7)
The answer is, therefore, B.
The answer should be B. This is because the negation next to the (a != b) is evaluated first, then you distribute the outside negation to the entire proposition.
Using DeMorgan's Laws, the && will switch to ||. Similarly, != becomes ==, and > becomes <=.
!(!(a != b) && (b > 7))
!((a == b) && (b > 7))
(a != b) || (b <= 7)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With