r/AskComputerScience • • Dec 16 '19

How does one attempt and visualize this?

Post image
35 Upvotes

19 comments sorted by

View all comments

1

u/midwayfair Dec 16 '19 edited Dec 16 '19

EDITED for a correction.

This isn't exactly a visualization, but I think it's probably better than trying to visualize it:

X is the set of numbers such that if n is in m, then n is not in L and n is not in H.

There are few enough numbers in the universe that you can run each number through the statement. Remember your truth table for P -> Q:

P    Q    P -> Q
T    T        T
T    F         F
F    T         T
F    F         T

If 1 is in M and 1 is not in L and 1 is not in H: P is false (1 is not in M), therefore the statement is true. Therefore n = 1 is in X.

If 2 is in M and 2 is not in L and 2 is not in H: P is true (2 is in M), but Q is false, since 2 is in L. Therefore the statement is false. Therefore n = 2 is not in X.

If 3 is in M and 3 is not in L and 3 is not in H: P is true (3 is in M), but Q is false, since 3 is in H. Therefore the statement is false. Therefore n = 3 is not in X.

If 4 is in M and 4 is not in L and 4 is not in H: P is false (4 is not in M), therefore the statement is true. Therefore n = 4 is in X.

X = {1, 4} then.

2

u/narut0fan Dec 16 '19

Your truth table for P->Q is wrong. Look it up again. If P is False, P->Q returns True.

1

u/midwayfair Dec 16 '19 edited Dec 16 '19

You're right. I'm a dolt.

EDIT: The worst part is, until I typed out the truth table, I was going to tell them that the answer was 1, 4 ... and then I fixed my answer to match the wrong truth table (which was the AND table).