Friday, February 25, 2011

Practice for logical operators

The editor for blog posts doesn't have a symbol that looks like the arrow for implication, so these are the symbols I will use here for the logical operators.

^ is AND
v is OR
~ is NOT
=> is IMPLIES

p = 1101
q = 1000
r = 0110

Find the bitstrings that correspond to these logical operations.

a) p v q
b) p ^ ~r
c) r => q
d) ~r => q
e) ~(r => q)
f) p v q ^ r


Answers in the comments.


More practice problems here .

1 comment:

Prof. Hubbard said...

p = 1101
q = 1000
r = 0110

Find the bitstrings that correspond to these logical operations.

a) p v q = 1101
With OR, we only get a 0 if both bitstrings have a 0 in the same position.

b) p ^ ~r = 1001
~r = 1001, and p = 1101, so the first and last bit positions have 1s in both strings, which show up in the answer to AND.

c) r => q = 1001
If r has a 0 in any position, the answer will have a 1 in that position. When r has a 1 in a position, look to see what is in the conclusion q to see what those positions will look like in the answer.

d) ~r => q = 1110
~r = 1001, which means 1s in the middle two positions in the answer for sure, and another 1 in the first position because there is a 1 in that position in q.

e) ~(r => q) = 0110
This is the NOT of answer c).

f) p v q ^ r = 0100
p v q is 1101 up in answer a), then we AND that answer with r. The only place where both these patterns have a 1 is the second position.