Solution to Exam 1, Fall '13 [PDF]

Solution to Exam 1, Fall '13 [PDF] Solution to Exam 1, Fall '13 [PDF]

php.scripts.psu.edu
from php.scripts.psu.edu More from this publisher
28.12.2013 Views

CMPSC 360 Discrete Mathematics for Computer Science Fall 2013 Exam I: Logic September 16, 2013 Name: Annotated Solution Last 4 digits of ID: ____ ____ ____ ____ In addition to correct solutions to each problem, this document will also give some commentary and strategies for understanding how to solve some problems, particularly where that seems like it would be most helpful. Honor Code Statement I certify that I have not discussed the contents of the exam with any other student and I will not discuss the contents of this exam with any student in this class before it is returned to me with a grade. I have not cheated on this exam in any way, nor do I know of anyone else who has cheated. Signature: _________________________________________________________ Directions/Notes: • Write your name just on this cover page. Write your ID on every page of this exam. (This is very important this time. We will almost certainly disassemble your exam to grade problems in parallel. If we waste time because you didn't follow this direction, you will be penalized. If we cannot match a sheet of your exam back to the rest of your exam because you did not follow this direction, you will not earn credit on that sheet.) • No notes, books, or calculators are permitted. • Be sure to sign the honor code statement when you are finished. • All questions on this exam are implicitly prefaced with “As taught in CMPSC 360 lectures this term.” • Always justify your work and present solutions using the conventions taught in class. • Use pencil to complete this exam. Use of pen will result in an automatic 10-point deduction and we reserve the right not to read any problem with cross-outs. • It is acceptable to use the shorthand “LHS” to refer to the left-hand side of an equivalence in writing a proof. • In algebraic substitutions, you may only use laws from our list of equivalences, not anything derived as a result of some problem or example. Score Breakdown: # 1 2 3 4 5 6 7 8 9 10 11 AP Total Score Value 8 8 6 12 6 13 10 8 14 10 7 -- 100

CMPSC 360<br />

Discrete Mathematics for Computer Science<br />

<strong>Fall</strong> 2013<br />

<strong>Exam</strong> I: Logic<br />

September 16, 2013<br />

Name: Annotated <strong>Solution</strong> Last 4 digits of ID: ____ ____ ____ ____<br />

In addition <strong>to</strong> correct solutions <strong>to</strong> each problem, this document will also give some commentary and strategies for<br />

understanding how <strong>to</strong> solve some problems, particularly where that seems like it would be most helpful.<br />

Honor Code Statement<br />

I certify that I have not discussed the contents of the exam with any other student and I will not discuss the contents<br />

of this exam with any student in this class before it is returned <strong>to</strong> me with a grade. I have not cheated on this exam in<br />

any way, nor do I know of anyone else who has cheated.<br />

Signature: _________________________________________________________<br />

Directions/Notes:<br />

• Write your name just on this cover page. Write your ID on every page of this exam.<br />

(This is very important this time. We will almost certainly disassemble your exam <strong>to</strong> grade problems in parallel. If we waste time<br />

because you didn't follow this direction, you will be penalized. If we cannot match a sheet of your exam back <strong>to</strong> the rest of your exam<br />

because you did not follow this direction, you will not earn credit on that sheet.)<br />

• No notes, books, or calcula<strong>to</strong>rs are permitted.<br />

• Be sure <strong>to</strong> sign the honor code statement when you are finished.<br />

• All questions on this exam are implicitly prefaced with “As taught in CMPSC 360 lectures this term.”<br />

• Always justify your work and present solutions using the conventions taught in class.<br />

• Use pencil <strong>to</strong> complete this exam. Use of pen will result in an au<strong>to</strong>matic 10-point deduction and we<br />

reserve the right not <strong>to</strong> read any problem with cross-outs.<br />

• It is acceptable <strong>to</strong> use the shorthand “LHS” <strong>to</strong> refer <strong>to</strong> the left-hand side of an equivalence in writing a<br />

proof.<br />

• In algebraic substitutions, you may only use laws from our list of equivalences, not anything derived as<br />

a result of some problem or example.<br />

Score Breakdown:<br />

# 1 2 3 4 5 6 7 8 9 10 11 AP Total<br />

Score<br />

Value 8 8 6 12 6 13 10 8 14 10 7 -- 100


CMPSC 360 <strong>Exam</strong> 1 – <strong>Fall</strong> 2013 – Page 2<br />

Last 4 Digits of ID: ___ ___ ___ ___<br />

1. Build a truth table for the following expression: ~(p ∨ q) ↔ (q ∧ ~p) [8 pts.]<br />

p q p ∨ q ~(p ∨ q) ~p (q ∧ ~p) ~(p ∨ q) → (q ∧ ~p) (q ∧ ~p) → ~(p ∨ q) ~(p ∨ q) ↔ (q ∧ ~p)<br />

T T T F F F T T T<br />

T F T F F F T T T<br />

F T T F T T T F F<br />

F F F T T F F T F<br />

2. Prove the following logical equivalence algebraically: (p ∨ q) ∧ ~(p ∧ q) ≡ (p ∨ q) ∧ (p → ~q) ∧ (q → ~p) [8 pts.]<br />

(p ∨ q) ∧ ~(p ∧ q) ≡ (p ∨ q) ∧ (~p ∨ ~q) by De Morgan's law<br />

≡ (p ∨ q) ∧ (~p ∨ ~q) ∧ (~p ∨ ~q)<br />

by idempotent law<br />

≡ (p ∨ q) ∧ (~p ∨ ~q) ∧ (~q ∨ ~p)<br />

by commutative law<br />

≡ (p ∨ q) ∧ (p → ~q) ∧ (q → ~p) by "or" def. of → ❑<br />

Comment: This was, of course, the problem that was given in recitation in Week 2 and you were strongly encouraged <strong>to</strong> do,<br />

so it should have been very familiar.<br />

3. In each part, you are given a claim that is either true or false. In a complete sentence, either assert it is true with a<br />

concrete proof or assert it is false with concrete disproof.<br />

[6 pts.]<br />

a. Given the sets A = {x ∈ R | 0 < x < 3} and B = {e, π}, B ⊆ A.<br />

B ⊈ A, as π ∈ B but π ∉ A.<br />

b. (6, Z) = ( 3 2 − 3 , {…, -2, -1, 0, 1, 2, …})<br />

(6, Z) = (3 2 - 3, {…, -2, -1, 0, 1, 2, …}), as 6 = 3 2 - 3 and Z = {…, -2, -1, 0, 1, 2, …}<br />

Comments:<br />

1. These questions were <strong>to</strong> follow up on the quiz from Chapter 1, but also <strong>to</strong> reinforce the idea of working from<br />

definitions.<br />

2. Your sentences needed <strong>to</strong> be specific. "B ⊈ A" is much more specific than "the claim is false" (and a lot less writing<br />

on your part <strong>to</strong>o).<br />

3. Remember that the definition for subsethood is a universal conditional. For a generic universal conditional statement<br />

∀x ∈ D [P(x) → Q(x)], the negation is ∃x ∈ D [P(x) ∧ ~Q(x)], and so the strategy for claiming something doesn't<br />

meet a universal conditional is always the same: exhibit an x in the domain for which P(x) is true but for which Q(x)<br />

is false, exactly what the negation says. So, here, you just needed <strong>to</strong> give a specific element of B that was not in A.<br />

(This question was <strong>to</strong> be a nice connection from Chapter 1 <strong>to</strong> Chapter 3. Did you make the connection? Hopefully<br />

you do now!)


CMPSC 360 <strong>Exam</strong> 1 – <strong>Fall</strong> 2013 – Page 3<br />

Last 4 Digits of ID: ___ ___ ___ ___<br />

4. Suppose you're walking on campus observing and you pause near a tree by a sidewalk <strong>to</strong> observe the set of animals in<br />

your view. Let's call that set A. We have lots of squirrels and rabbits here, so let S be the set of squirrels in your view and<br />

let R be the set of rabbits in your view. (By definition, S ⊆ A and R ⊆ A.)<br />

[12 pts.]<br />

Define the following predicates on any input x from A:<br />

UnderTree(x) ≡ x is under the tree<br />

OnSidewalk(x) ≡ x is on the sidewalk<br />

Note: Only the final number <strong>to</strong> the <strong>to</strong>p right of this problem matters in grading. We left some other numbers on papers<br />

<strong>to</strong> help sort papers in<strong>to</strong> piles when grading – don't worry about those. The final score was determined by your work on<br />

all parts of the problem as a whole.<br />

a. Using the sets and predicates defined above, translate each statement <strong>to</strong> symbolic logic notation.<br />

i. All squirrels are on the sidewalk.<br />

∀x ∈ A, x ∈ S → OnSidewalk(x)<br />

Comment: You could also write this as "∀x ∈ S, OnSidewalk(x)" and many did. However, for it <strong>to</strong> make<br />

any sense for you <strong>to</strong> answer part (b), your response here would have <strong>to</strong> be a universal conditional<br />

statement.<br />

ii. There are at most two squirrels under the tree.<br />

~∃x ∈ S ∃y ∈ S ∃z ∈ S [UnderTree(x) ∧ UnderTree(y) ∧ UnderTree(z) ∧ x ≠ y ∧ y ≠ z ∧ x ≠ z]<br />

Comment: Remember that "at most two" is equivalent <strong>to</strong> "not at least three," and that's exactly the mindset<br />

of the translation here. This can be done with universal quantifiers <strong>to</strong>o – and you can feed the negation<br />

through and apply the "or" definition of the conditional <strong>to</strong> get that form – but it's trickier. Be very careful:<br />

"at most two" only states an upper bound on the number of squirrels; it does not say anything about a<br />

lower bound. A common error here was <strong>to</strong> use existential quantifiers without the negation out front, but that<br />

nearly always says there's at least one squirrel under the tree. Indeed, there could be none.<br />

iii. If there are at least two squirrels on the sidewalk, the rabbit is under the tree.<br />

∃x ∈ S ∃y ∈ S [OnSidewalk(x) ∧ OnSidewalk(y) ∧ x ≠ y] → ∃z ∈ R [(∀x ∈ R → x = z) ∧ UnderTree(z)]<br />

Comment: This one was really two independent logical statements, connected by a conditional. The<br />

variables for the squirrels and the rabbit are unrelated. Placement of parentheses or brackets can affect<br />

meaning significantly. Also, note that we don't say our "at least two" squirrels exist; their existence is<br />

conditional. The rabbit definitely exists, and you could speak of the rabbit first if you want, but vacuous<br />

truth makes the rabbit exist in the form here.<br />

b. Express the contrapositive of Statement (i) in Part (a) in English.<br />

All animals that are not on the sidewalk are not squirrels.<br />

5. What is the difference between an inclusive "or" and an exclusive "or"? Give a real-life example where exclusive "or"<br />

makes sense but inclusive does not. Express the notion of an exclusive "or" of two a<strong>to</strong>mic statements symbolically in<br />

four distinctly different ways.<br />

[6 pts.]<br />

Sentences formed using both opera<strong>to</strong>rs are true when exactly one of the operands is true. An inclusive "or" is true when<br />

both operands are true, whereas an exclusive "or" is not. Real-life examples vary (and were interesting <strong>to</strong> read).<br />

Ways <strong>to</strong> express exclusive "or":<br />

(p ∨ q) ∧ ~(p ∧ q)<br />

(p ∧ ~q) ∨ (q ∧ ~p) [This is disjunctive normal form]<br />

(p ∨ q) ∧ (p → ~q) ∧ (q → ~p) [As per problem left for you in recitation / #2]<br />

~(p ↔ q)<br />

[As per problem left for you in recitation]<br />

Comment: The exclusive "or" forms needed <strong>to</strong> be distinctly different, and this problem partly served <strong>to</strong> see if you got<br />

the takeaway lessons from the problems that were recommended <strong>to</strong> you at the end of Week 2's recitation.


CMPSC 360 <strong>Exam</strong> 1 – <strong>Fall</strong> 2013 – Page 4<br />

Last 4 Digits of ID: ___ ___ ___ ___<br />

6. Define AL <strong>to</strong> be the set of Major League Baseball teams in the American League. The American League is partitioned<br />

in<strong>to</strong> three subsets: E, the AL East Division; C, the AL Central Division; and W, the AL West Division. We use the<br />

notation w-l <strong>to</strong> give a team's record, where w is the number of wins and l is the number of losses. As of September 4 1 ,<br />

here are the standings for the three divisions of the American League:<br />

East (E) Central (C) West (W)<br />

Bos<strong>to</strong>n (84-57)<br />

Tampa Bay (76-61)<br />

New York (75-64)<br />

Baltimore (73-65)<br />

Toron<strong>to</strong> (64-76)<br />

Detroit (81-59)<br />

Cleveland (74-65)<br />

Kansas City (72-67)<br />

Minnesota (61-77)<br />

Chicago (56-82)<br />

Oakland (80-59)<br />

Texas (80-59)<br />

LA (64-73)<br />

Seattle (63-76)<br />

Hous<strong>to</strong>n (46-93)<br />

Determine whether each statement is true or false (worth no credit but important <strong>to</strong> help us know your intentions) and<br />

prove or disprove each statement (worth all the credit).<br />

[13 pts.]<br />

a. ∃t ∈ AL s.t. t has at least 80 wins.<br />

True.<br />

Bos<strong>to</strong>n ∈ AL and Bos<strong>to</strong>n has at least 80 wins.<br />

Comment: You need <strong>to</strong> prove the statement by providing one example. Part of that is asserting the relevance of the<br />

example: the first part of the sentence should be noting that whatever team you want <strong>to</strong> discuss indeed is in the<br />

domain, i.e. it's an element of AL.<br />

b. ∀t ∈ AL, t has at least 80 losses → t ∈ C or t ∈ W<br />

True.<br />

Chicago has at least 80 losses and Chicago ∈ C or Chicago ∈ W.<br />

Hous<strong>to</strong>n has at least 80 losses and Hous<strong>to</strong>n ∈ C or Hous<strong>to</strong>n ∈ W.<br />

c. ∀t ∈ AL, t has at least twice as many wins as losses → t ∈ E<br />

True.<br />

There is no team t ∈ AL s.t. t has twice as many wins as losses, so this statement is vacuously true.<br />

Comment: Don't misinterpret vacuous truth as false; if no element of the domain satisfies the hypothesis of a<br />

universal conditional statement, that statement is indeed true – vacuously true.<br />

d. ∀t ∈ E, ∃s ∈ C s.t. s has fewer wins than t<br />

True.<br />

Bos<strong>to</strong>n ∈ E and Detroit ∈ C and Detroit has fewer wins than Bos<strong>to</strong>n.<br />

Tampa Bay ∈ E and Chicago ∈ C and Chicago has fewer wins than Tampa Bay.<br />

New York ∈ E and Chicago ∈ C and Chicago has fewer wins than New York.<br />

Baltimore ∈ E and Chicago ∈ C and Chicago has fewer wins than Baltimore.<br />

Toron<strong>to</strong> ∈ E and Chicago ∈ C and Chicago has fewer wins than Toron<strong>to</strong>.<br />

Comment: For this statement and the next, you need <strong>to</strong> prove the universal claim true via exhaustion. In each case,<br />

you must spell out all five teams in E. Note that the order of quantifiers is different, and indeed, the interpretations<br />

of the sentences differ. We wanted you <strong>to</strong> exhaust the details completely <strong>to</strong> show your understanding of quantifiers.<br />

e. ∃s ∈ C s.t. ∀t ∈ E, s has fewer wins than t<br />

True.<br />

Chicago ∈ C and Bos<strong>to</strong>n ∈ E and Chicago has fewer wins than Bos<strong>to</strong>n<br />

and Tampa Bay ∈ E and Chicago has fewer wins than Tampa Bay<br />

and New York ∈ E and Chicago has fewer wins than New York<br />

and Baltimore ∈ E and Chicago has fewer wins than Baltimore<br />

and Toron<strong>to</strong> ∈ E and Chicago has fewer wins than Toron<strong>to</strong>.<br />

1 when most of the exam was written, <strong>to</strong> give plenty of time <strong>to</strong> proofread and copy


CMPSC 360 <strong>Exam</strong> 1 – <strong>Fall</strong> 2013 – Page 5<br />

Last 4 Digits of ID: ___ ___ ___ ___<br />

7. Determine, via formal proof or disproof, whether the following argument form is valid: [10 pts.]<br />

p ∨ ~q<br />

q → r<br />

p ∨ r → q ∧ p<br />

∴ r ∨ p<br />

We construct a truth table <strong>to</strong> check the validity of this argument form:<br />

premises<br />

conclusion<br />

p q r ~q p ∨ r q ∧ p p ∨ ~q q → r p ∨ r → q ∧ p r ∨ p<br />

T T T F T T T T T T<br />

T T F F T T T F T<br />

T F T T T F T T F<br />

T F F T T F T T F<br />

F T T F T F F T F<br />

F T F F F F F F T<br />

F F T T T F T T F<br />

F F F T F F T T T F<br />

The first and eighth rows are critical rows. As the conclusion is false in one of the critical rows (the bot<strong>to</strong>m row), the<br />

argument form is not valid.<br />

Comment: As happens pretty much every semester, results on this question were at the extremes. The vast majority of<br />

you did rather well. Some did not try a technique that was right, but remember that there's only one technique we used<br />

for proving the validity of an argument form and it is this one. See the beginning of the class notes from Section 2.3 <strong>to</strong><br />

review if you've forgotten the technique.<br />

8. We say a statement is in conjunctive normal form (CNF) when [8 pts.]<br />

a. All logical connectives that are not in parentheses are "and."<br />

b. All logical connectives that in parentheses are "or."<br />

c. The "not" operation may be used inside parentheses, but not outside.<br />

In other words, the statement is a conjunction ("and" statement) of disjunctions ("or statements) of a<strong>to</strong>mic sentences.<br />

Here are some examples:<br />

p ∧ q (p ∨ q) ∧ (~q ∨ r) (p ∨ q ∨ ~r) ∧ (~p ∨ ~q ∨ r)<br />

Convert the following statement <strong>to</strong> conjunctive normal form, justifying all work and presenting work like in a proof:<br />

p ↔ q ∧ r<br />

p ↔ q ∧ r ≡ (p → q ∧ r) ∧ (q ∧ r → p) by "or" def. of →<br />

≡ (~p ∨ (q ∧ r)) ∧ (~(q ∧ r) ∨ p) by "or" def. of →<br />

≡ (~p ∨ (q ∧ r)) ∧ ((~q ∨ ~r) ∨ p) by De Morgan's law<br />

≡ ((~p ∨ q) ∧ (~p ∨ r)) ∧ ((~q ∨ ~r) ∨ p) by distributive law<br />

≡ (~p ∨ q) ∧ (~p ∨ r) ∧ (~q ∨ ~r ∨ p) as dropping parentheses doesn't introduce ambiguity<br />

Comment: Most responses fell in<strong>to</strong> one of three categories: completely right or nearly right, suffering from problems<br />

with parentheses, and problems with the order of operations. As far as parenthesis go, pay very close attention <strong>to</strong> add<br />

them in applying the definition of the biconditional in the first line. To say "p → q ∧ r ∧ q ∧ r → p" is unclear;<br />

parentheses are needed. Some forgot the order of operations; remember that condi<strong>to</strong>nals and biconditionals are evaluated<br />

last in a line. Unfortunately, while getting the order of operations wrong might be a single error, doing so makes it that<br />

you miss the ability <strong>to</strong> do most of the derivation.


CMPSC 360 <strong>Exam</strong> 1 – <strong>Fall</strong> 2013 – Page 6<br />

Last 4 Digits of ID: ___ ___ ___ ___<br />

9. Consider the following premises: [14 pts.]<br />

(a) x<br />

(b) r ∨ s → y<br />

(c) ~w ∨ ~x<br />

(d) y → (z → ~p)<br />

(e) r ∧ x → (q ∨ z)<br />

(f) ~r → w<br />

(g) q → ~p<br />

a. Use the premises given above <strong>to</strong> deduce the conclusion ~p.<br />

If you are unable <strong>to</strong> solve the problem as written, instead aim for "(q ∨ z) ∧ (z → p)" and circle this sentence (for up <strong>to</strong> 10/12 points on this part).<br />

(1) ~w by ∨ Elim: c, a<br />

(2) ~~r by modus <strong>to</strong>llens: f, 1<br />

(3) r by double negation: 2<br />

(4) r ∨ s → (z → ~p) by transitivity: b, d<br />

(5) r ∨ s by ∨ Intro: 3<br />

(6) z → ~p by modus ponens: 4, 5<br />

(7) r ∧ x by definition of ∧: 3, a<br />

(8) q ∨ z by modus ponens: e, 7<br />

(9) ~p by cases: 8, g, 6<br />

Comment: Here we had several perfect or nearly perfect solutions, which is good news. But, like the problem set,<br />

some responses did not use the rules of inference correctly or used rules that don't exist, which does not work. For<br />

example, consider statement (4): r ∨ s → (z → ~p). To be able <strong>to</strong> use modus ponens, you must first have the exact<br />

form of the hypothesis. This is why the ∨ Introduction step (Step 5) is necessary. If you struggled here, work more<br />

with the rules of inference. This problem was designed <strong>to</strong> require you <strong>to</strong> use most of the rules (with transitivity be<br />

optional).<br />

b. Suppose premise (f) were replaced with the statement "~w → r." Would you be able <strong>to</strong> deduce the same conclusion?<br />

Explain.<br />

This statement is simply the contrapositive of premise (f). As a statement is logically equivalent <strong>to</strong> its contrapositive,<br />

making this substitution would allow us <strong>to</strong> deduce the same conclusion.


CMPSC 360 <strong>Exam</strong> 1 – <strong>Fall</strong> 2013 – Page 7<br />

Last 4 Digits of ID: ___ ___ ___ ___<br />

10. Prove the following logical equivalence algebraically: [10 pts.]<br />

∀ε > 0 (∃N (∀n (n > N → |x n – L| < ε))) ≡ ~∃ε > 0 (∀N (∃n (n > N ∧ |x n – L| ≥ ε)))<br />

[For one extra-credit point, what is the meaning of this? It came up in an indirect prerequisite of this course.]<br />

∀ε > 0 (∃N (∀n (n > N → |x n – L| < ε))) ≡ ~~∀ε > 0 (∃N (∀n (n > N → |x n – L| < ε))) by double negation<br />

≡ ~∃ε > 0 ~(∃N (∀n (n > N → |x n – L| < ε))) by De Morgan's for quant.<br />

≡ ~∃ε > 0 (∀N ~(∀n (n > N → |x n – L| < ε))) by De Morgan's for quant.<br />

≡ ~∃ε > 0 (∀N (∃n ~(n > N → |x n – L| < ε))) by De Morgan's for quant.<br />

≡ ~∃ε > 0 (∀N (∃n ~(~(n > N) ∨ |x n – L| < ε))) by "or" def. of →<br />

≡ ~∃ε > 0 (∀N (∃n (~~(n > N) ∨ ~(|x n – L| < ε)))) by De Morgan's law<br />

≡ ~∃ε > 0 (∀N (∃n (n > N ∨ ~(|x n – L| < ε)))) by double negation<br />

≡ ~∃ε > 0 (∀N (∃n (n > N ∨ |x n – L| ≥ ε))) by negating "

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!