I'm a little confused on !a&&(a||b)
. If I look at it directly and interpret it simply, it appears as if it is the same as
!a&&a or !a&&b
but this seems a little weird because since a
can't be true and false, it would only be true if the latter was true. I also interpreted it like this
!a || a&&b
I don't really know how I came up with this one but it just looks more logical since there are no contradictions. Can anyone help me on this please?
| a | b | !a | a || b | !a && (a || b) | !a && b | [ !a && (a || b) ] <=> [!a && b] |
|---|---|----|--------|------------------|---------|-------------------------------------|
| 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 | 1 |
According to the Principle of Distributivity statement !a && (a || b)
is equivalent to (!a && a) || (!a && b)
.
Accordiong to the Law of Non-Contradiction (!a && a)
is equivalent to false
Putting it all together:
!a && (a || b) <=> (!a && a) || (!a && b) <=> false || (!a && b) <=> !a && b
You can simplify it like this (!a && b)
because in expression (!a && a || !a && b)
the condition !a && a
is always false
In Java like in most 1 languages the unary !
has higher precedence than &&
.
So !a&&(a||b)
is (!a)&&(a||b)
You can represent the truth table of that expression using a Karnaugh map:
| a = 0 | a = 1 |
------+-------+-------+
b = 0 | 0 | 0 |
------+-------+-------+
b = 1 | 1 | 0 |
------+-------+-------+
Now, it can easily be seen that the only true case is when (!a) && b
.
So !a&&(a||b)
is !a && b
1See comments below.
It simply means !a && b
, a must be false and b must be true, for it to be true
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