0% found this document useful (0 votes)
51 views10 pages

CMPSC 360 Midterm 1A Solutions

The document contains the solutions to Midterm 1A for CMPSC 360, Discrete Mathematics for Computer Science, at Pennsylvania State University. It includes five problems covering topics such as logic, set theory, and proofs, with detailed answers and logical reasoning provided for each. The exam format is closed-book, with specific instructions on how to complete the exam and allocate time effectively.

Uploaded by

gorgefloid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views10 pages

CMPSC 360 Midterm 1A Solutions

The document contains the solutions to Midterm 1A for CMPSC 360, Discrete Mathematics for Computer Science, at Pennsylvania State University. It includes five problems covering topics such as logic, set theory, and proofs, with detailed answers and logical reasoning provided for each. The exam format is closed-book, with specific instructions on how to complete the exam and allocate time effectively.

Uploaded by

gorgefloid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CMPSC 360: Dr.

Anton Bankevich
Discrete Mathematics for CS Pennsylvania State University

Midterm 1A Solutions
• Do not open this exam booklet until you are directed to do so. Read all the instructions on this
page.

• This exam contains five problems. You have 75 minutes to earn 100 points.

• This exam booklet contains 10 pages, including this one. An additional sheet of scratch paper is
attached. Do not detach it when submitting your exam.

• This is a closed-book exam.


Calculators, mobile, smart watches, or programmable devices are not permitted.
The reverse side of this sheet contains the standard reference sheet with essential facts for this
exam.

• Write your solutions in the space provided. If you need more space, write on the extra sheet
attached at the end of this booklet.

• Do not spend too much time on any one problem. Read all of them first, and attempt them in
the order that allows you to make the most progress.

• Show your work as partial credit will be given. You will be graded not only on the correctness
of your answer, but also on the clarity with which you express it. Be neat.

• Good luck!

Name: ID(email):
Section:

Problem 1 2 3 4 5 Total

Points 20 20 20 20 20 100

Grade
Basic logic equivalences
p∧T ≡p p ∨ ¬p ≡ T
Identity laws Negation laws
p∨F ≡p p ∧ ¬p ≡ F
p∨T ≡T p∨p≡p
Domination laws Idempotent laws
p∧F ≡F p∧p≡p
p ∨ (p ∧ q) ≡ p
Double negation law ¬¬p ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p
¬(p ∧ q) ≡ ¬p ∨ ¬q p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
De Morgan laws Distributive laws
¬(p ∨ q) ≡ ¬p ∧ ¬q p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
p∨q ≡q∨p (p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
Commutative laws Associative laws
p∧q ≡q∧p (p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
Universal negation ¬∀xP (x) ≡ ∃x¬P (x) Existence negation ¬∃xP (x) ≡ ∀x¬P (x)
Inference rules
p → q, p p → q, ¬q
Modus ponens Modus tollens
∴q ∴ ¬p
p → q, q → r p ∨ q, ¬p
Hypothetical syllogism Disjunctive syllogism
∴p→r ∴q
Addition p Proof by cases p → r, q → r, p ∨ q
(Disjunction introduction) ∴p∨q (Disjunction elimination) ∴r
p, q Simplification p∧q
Simplification introduction
∴p∧q (Conjunction elimination) ∴p

∀xP (x)
Universal instantiation For any term t
∴ P (t)
Where x is a free variable that is
P (x)
Universal generalization not present as a free variable in any
∴ ∀xP (x)
premises
Where c is a new constant name that
∃xP (x)
Existential instantiation was not used in the proof or present
∴ P (c)
(for simple cases) in premises
Where C is a new function name that
∃xP (x, y1 , . . . , yn )
Existential instantiation depends on all free variables of P ex-
∴ P (C(y1 , ..., yn ), y1 , ..., yn )
(for multiple free variables) cept x
∃xP (x), P (x) → Q Where Q does not contain x as a free
Existential instantiation
∴Q variable
(formal form)
P (t)
Existential generalization For any term t
∴ ∃xP (x)

Proof techniques
Name Assume Prove Conclusion
Direct proof p q p→q
Proof by contrapositive ¬p ¬q q→p
Proof by contradiction ¬p F (contradiction) p
Proof by contradiction
p, ¬q F (contradiction) p→q
(for implication)
CMPSC 360 Midterm 1A, page 3

Problem 1. (System Specifications) (20 pts)


Use a truth table to identify all states that satisfy the following system specification:

1. The message is encrypted only if it is confidential.

2. The message is not encrypted unless it is stored securely.

3. The message is not confidential.

4. If the message is stored securely, then it is confidential.

Answer:
Let C: The message is confidential. E: The message is encrypted. S: The message is stored
securely.
1. The message is encrypted only if it is confidential: E → C.
2. The message is not encrypted unless it is stored securely: E → S.
3. The message is not confidential: ¬C.
4. If the message is stored securely, then it is confidential: S → C.

C E S E → C E → S S → C ¬C All
T T T T T T F F
T T F T F T F F
T F T T T T F F
T F F T T T F F
F T T F T F T F
F T F F F T T F
F F T T T F T F
F F F T T T T T
System is consistent.
CMPSC 360 Midterm 1A, page 4

Problem 2. (Logic) (20 pts)


Use logical equivalences to demonstrate that logic circuit A and logic circuit B always
produce the same results or provide an input that contradicts this statement. Clearly label
each logical identity used in your proof.

Answer:
Logic circuit A: (¬p ∨ q) ∧ (¬p ∨ r)
Logic circuit B: ¬(p ∧ (¬q ∨ ¬r)

¬(p ∧ (¬q ∨ ¬r) ≡


≡ ¬p ∨ (q ∧ r) (De Morgan’s law)
≡ (¬p ∨ q) ∧ (¬p ∨ r) (Distributive law)

Logic formulas for circuits A and B are equivalent. Circuits always produce the same result.
CMPSC 360 Midterm 1A, page 5

Problem 3. (Set Theory) (20 pts)


Let U be the universal set, and A, B, C be subsets of U. Simplify the expression below
using set equivalences, and create a Venn diagram to visually represent the resulting set.
Clearly label each equivalence used, mark all regions on the Venn diagram, and shade the
final result.
(B − A) ∪ (A ∩ (B ∪ C))
Answer:

(B − A) ∪ (A ∩ (B ∪ C))
= (B − A) ∪ (A ∩ B ∩ C) (De Morgan’s Law)
= (B ∩ A) ∪ (A ∩ B ∩ C) (Set Difference)
CMPSC 360 Midterm 1A, page 6

Problem 4. (Proofs) (20 pts)


Formally prove the following statement using the contrapositive approach: if x3 −2x2 > 0
then x > 0.
In the formal proof, enumerate all steps and clearly indicate each application of an
inference rule. For each predicate logic inference rule used, provide an explanation of why it
applies to the given situation.
Answer:
Proof. We will proceed using proof by contrapositive. For the rest of the proof, assume that
the domain is R.

1. Assume that x ≤ 0 for the sake of proving the contrapositive. [Premise]

2. We know the basic properties of real numbers:


 
(a) ∀x (x ≤ 0) → (x3 ≤ 0) [Known Property]
(b) (x ≤ 0) → (x3 ≤ 0) [Universal instantiation on (a) for term x]
(c) x3 ≤ 0 [Modus Ponens on (b) and (1.)]
(d) ∀x (−2x2 ≤ 0) [Known Property]
(e) −2x2 ≤ 0 [Universal instantiation on (d) for term x]
(f) x3 ≤ 0 ∧ −2x2 ≤ 0 [Conjunction on (c) and (e)]
 
(g) ∀x∀y (x ≤ 0 ∧ y ≤ 0) → (x + y ≤ 0) [Known Property]
(h) (x3 ≤ 0 ∧ −2x2 ≤ 0) → (x3 − 2x2 ≤ 0) [Universal instantiation on (g) for term
x3 and −2x2 ]
(i) x3 − 2x2 ≤ 0 [Modus Ponens on (f) and (h)]

3. (x ≤ 0) → (x3 − 2x2 ≤ 0) [Proved using proof by contrapositive]


 
3 2
4. ∀x (x ≤ 0) → (x − 2x ≤ 0) (Universal Generalization on (c) for term x)
 
3 2
5. By the contrapositive, it follows that ∀x (x − 2x > 0) → (x > 0) .

Alternatively, students may start with “1. We know the basic properties of real numbers
...” and write the assumption x ≤ 0 as step 1(a)
CMPSC 360 Midterm 1A, page 7

Problem 5. (Proofs) (20 pts)


Provide a formal proof that the argument below is valid.
Hypothesis 1: ∀x∃y P (x, y)
Hypothesis 2: ∀x∃y Q(x, y)
Hypothesis 3: ∀x∀y∀z (P (x, y) ∧ Q(x, z) → R(x))
Conclusion: ∀xR(x)

In the formal proof, enumerate all steps and clearly indicate each application of an in-
ference rule. For each predicate logic inference rule used, provide an explanation of why it
applies to the given situation.
Answer:

(a) ∃yP (x, y) [Universal Instantiation on H1 for term x]

(b) P (x, C1 (x)) [Existential Instantiation on (a) for new function symbol C1 ]

(c) ∃yQ(x, y) [Universal Instantiation on H2 for term x]

(d) Q(x, C2 (x)) [Existential Instantiation on (c) for new function symbol C2 ]

(e) P (x, C1 (x)) ∧ Q(x, C2 (x)) [Conjunction on (b) and (d)]

(f) P (x, C1 (x)) ∧ Q(x, C2 (x)) → R(x) [Universal Instantiation thrice on H3 for terms x,
C1 (x), and C2 (x)]

(g) R(x) [Modus Ponens on (e) and (f)]

(h) ∀xR(x) [Universal Generalization on (g) for term x]


CMPSC 360 Midterm 1A, page 8

— Extra space. —
CMPSC 360 Midterm 1A, page 9

— Extra space. —
CMPSC 360 Midterm 1A, page 10

You might also like