Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm having issues with applying De Morgan's Law ... Feedback?

Every time one of these questions comes up in my assignments I get it wrong...can anyone help me understand? Or is the teacher's key off? (There is no way for me to know as I'm not given the correct answer, it only lets me know that mine is wrong.)

Assume x = 7 and y = 5. Applying De Morgan's Law, select the logical expression below that is equivalent to the following logical expression: !(x>5)||!(y>7)

(a) !(x>5)&&!(y>7)

(b) !((x>5)||(y>7))

(c) !(x>5)&&(y>7)

(d) (x>5)||!(y>7)

(e) None of the above

I would select B as the answer, but since I have gotten them all wrong so far I'm afraid to continue without some help.

The way I understand this it that you can consolidate the two ! into one by putting it in front of the whole statement, changing:

!(a)||!(b)

to

!((a)||(b))

like image 541
Mike Avatar asked Dec 10 '22 09:12

Mike


1 Answers

According to Wikipedia, de Morgan's Law (which to me was just a thing I knew) is

NOT (P AND Q) = (NOT P) OR (NOT Q)

In your question, P maps to (x>5) and Q maps to (y>7). Therefore !((x>5)&&(y>7)) is your answer. But you don't have such a one in your list. (Your teacher is sloppy if this is your real question, since only one proposed answer has double round brackets, which is a huge clue - you can rule out b because it still uses || and rule out the others for a lack of double round brackets, going straight to e.)

If you really can't make these things stand still for you, use the sample values the question provides. (If neccessary, make some up.) x>5 is true for x=7. y>7 is false for y=5. so you have !true || !false, which is false || true, which is true. Evaluate each of the possible expressions and rule out the ones that don't come out to the same answer. If you're still lost, pick different sample values and repeat. One of the possible answers will keep matching, or none will so you'll go with "none of the above." That will earn you the mark even if you don't really understand why.

As for why, it's because of the opposite behaviour of && and ||. The only way you get a true from && is with true on both sides. The only way you get a false from || is with false on both sides. If you flip the parameters with !, you can flip the operator and get the opposite result.

like image 95
Kate Gregory Avatar answered Dec 27 '22 01:12

Kate Gregory