University of California, San Diego Department of Computer Science and Engineering CSE 20. Solutions to Midterm Exam Winter 2018

Similar documents
Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

CSE20: Discrete Mathematics for Computer Science. Lecture Unit 2: Boolan Functions, Logic Circuits, and Implication

Exercise Set 1 Solutions Math 2020 Due: January 30, Find the truth tables of each of the following compound statements.

Math 10850, fall 2017, University of Notre Dame

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Tautologies, Contradictions, and Contingencies

~ p is always false. Based on the basic truth table for disjunction, if q is true then p ~

5. Use a truth table to determine whether the two statements are equivalent. Let t be a tautology and c be a contradiction.

CSC Discrete Math I, Spring Propositional Logic

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

Logic and Propositional Calculus

Proofs. Joe Patten August 10, 2018

Equivalence and Implication

CHAPTER 1. MATHEMATICAL LOGIC 1.1 Fundamentals of Mathematical Logic

Section 1.3. Let I be a set. When I is used in the following context,

The following techniques for methods of proofs are discussed in our text: - Vacuous proof - Trivial proof

1.1 Language and Logic

Proposition/Statement. Boolean Logic. Boolean variables. Logical operators: And. Logical operators: Not 9/3/13. Introduction to Logical Operators

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

EECS 1028 M: Discrete Mathematics for Engineers

Topics in Logic and Proofs

Topic 1: Propositional logic

Chapter 1: Formal Logic

1.1 Language and Logic

Mathematics 220 Midterm Practice problems from old exams Page 1 of 8

Midterm: Sample 3. ECS20 (Fall 2017) 1) Using truth tables, establish for each of the two propositions below if it is a tautology, a contradiction

Definition 2. Conjunction of p and q

Mathematics 220 Homework 4 - Solutions. Solution: We must prove the two statements: (1) if A = B, then A B = A B, and (2) if A B = A B, then A = B.

Numbers that are divisible by 2 are even. The above statement could also be written in other logically equivalent ways, such as:

Contribution of Problems

Boolean Logic. CS 231 Dianna Xu

Sample Problems for all sections of CMSC250, Midterm 1 Fall 2014

CSE 20 DISCRETE MATH. Fall

MaanavaN.Com MA1256 DISCRETE MATHEMATICS. DEPARTMENT OF MATHEMATICS QUESTION BANK Subject & Code : MA1256 DISCRETE MATHEMATICS

8. Given a rational number r, prove that there exist coprime integers p and q, with q 0, so that r = p q. . For all n N, f n = an b n 2

III. Elementary Logic

Logic. Facts (with proofs) CHAPTER 1. Definitions

HW1 graded review form? HW2 released CSE 20 DISCRETE MATH. Fall

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Mat 243 Exam 1 Review

Propositional Logic: Semantics

Midterm Exam Solution

Direct Proof MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Direct Proof Fall / 24

Steinhardt School of Culture, Education, and Human Development Department of Teaching and Learning. Mathematical Proof and Proving (MPP)

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

Statements, Implication, Equivalence

MAT 101 Exam 2 Logic (Part I) Fall Circle the correct answer on the following multiple-choice questions.

Solutions to Homework I (1.1)

Math 230 Final Exam, Spring 2008

We last time we began introducing equivalency laws.

1.1 Statements and Compound Statements

Chapter 5. Number Theory. 5.1 Base b representations

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics. Introductory Notes in Discrete Mathematics Solution Guide

Practice Midterm Exam Solutions

Packet #1: Logic & Proofs. Applied Discrete Mathematics

Logic. Definition [1] A logic is a formal language that comes with rules for deducing the truth of one proposition from the truth of another.

1. Given the public RSA encryption key (e, n) = (5, 35), find the corresponding decryption key (d, n).

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Compound Propositions

Logic Overview, I. and T T T T F F F T F F F F

Math Real Analysis

Discrete Mathematics and Probability Theory Summer 2014 James Cook Midterm 1 (Version B)

2.2: Logical Equivalence: The Laws of Logic

Introduction to Decision Sciences Lecture 2

The statement calculus and logic

Show Your Work! Point values are in square brackets. There are 35 points possible. Tables of tautologies and contradictions are on the last page.

Foundation of proofs. Jim Hefferon.

Logic and Proofs. (A brief summary)

a. See the textbook for examples of proving logical equivalence using truth tables. b. There is a real number x for which f (x) < 0. (x 1) 2 > 0.

Mathematics for Computer Science Exercises from Chapter 3

Proof. Theorems. Theorems. Example. Example. Example. Part 4. The Big Bang Theory

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

UNIVERSITY OF VICTORIA DECEMBER EXAMINATIONS MATH 122: Logic and Foundations

CSE 20 DISCRETE MATH WINTER

MAT2345 Discrete Math

HANDOUT AND SET THEORY. Ariyadi Wijaya

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

MATH CSE20 Homework 5 Due Monday November 4

A Statement; Logical Operations

Logic and Proofs. (A brief summary)

Mathematical Reasoning (Part I) 1

Section 3.1 Statements, Negations, and Quantified Statements

Implications, Quantifiers, and Venn Diagrams. Implications Logical Quantifiers Venn Diagrams. Different Ways of Stating Implications

Propositional natural deduction

10 Problem 1. The following assertions may be true or false, depending on the choice of the integers a, b 0. a "

COT 2104 Homework Assignment 1 (Answers)

A statement is a sentence that is definitely either true or false but not both.

Chapter 1: The Logic of Compound Statements. January 7, 2008

Logic, Sets, and Proofs

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

CSE 311: Foundations of Computing. Lecture 2: More Logic, Equivalence & Digital Circuits

Discrete Mathematics Fall 2018 Midterm Exam Prof. Callahan. Section: NetID: Multiple Choice Question (30 questions in total, 4 points each)

Solutions to Sample Problems for Midterm

CISC-102 Winter 2016 Lecture 17

THE LOGIC OF COMPOUND STATEMENTS

Automata Theory and Formal Grammars: Lecture 1

1. Propositions: Contrapositives and Converses

Foundations of Mathematics MATH 220 FALL 2017 Lecture Notes

Proofs. Methods of Proof Divisibility Floor and Ceiling Contradiction & Contrapositive Euclidean Algorithm. Reading (Epp s textbook)

Transcription:

University of California, San Diego Department of Computer Science and Engineering CSE 20 Solutions to Midterm Exam Winter 2018 Problem 1 (30 points) a. The boolean function f(p, q) = (q p) ( q p) is specified in: disjunctive normal form (DNF) conjunctive normal form (CNF) neither Solution: Disjunctive normal form is OR of minterms, which is exactly what we have here. b. The statement form (p q) (q p) is: a tautology a contradiction neither Solution: If p = T and q = T, the statement is true. But if p = F and q = T, the statement is false. Also, this statement says that an implication implies its converse, which is certainly false. c. Let C be the set of all cats, and let D be the set of all dogs. Let S be the statement: Every cat hates every dog. Which of the following statements is logically equivalent to S? cat C, dog D, cat hatesdog cat C, dog D, dog hatescat ( ) cat C, dog D, cat does not hatedog ( cat C, dog D, cat does not hatedog ) None of these Solution: The statement S can be expressed as S: cat C, dog D, cat hatesdog in predicate logic. Consequently S: cat C, dog D, cat does not hatedog, where

we have replaced by and negated the predicate. It is now clear that the third choice is logically equivalent to S, since it is a double negation thereof. d. In the following statements, P is the set of primes, N is the set of natural numbers, and Z is the set of integers. Which of these statements are true and which are false? True False p q implies q p Any implication implies its contrapositive, and vice versa. There is an integer b > 1 such that the number 100 b (expressed in base-b) is a prime. 100 b = b 2 for any base b, and b 2 cannot be a prime. The sum of 21 8 and 21 8 is 21 16. 21 8 + 21 8 = 2(2 8 + 1), which is even, but 21 16 = 2 16 + 1 is odd. n N, 2n is not in P. If n = 1, then 2n = 2 is a prime. m Z, n Z, n is a factor of (m 2 + 3m 18). n = m + 6 is always a factor of m 2 + 3m 18 = (m + 6)(m 3). n 2 1 is divisible by 4 whenever n is an odd integer. If n = 2t + 1, then n 2 1 = (n 1)(n + 1) = 4t(t + 1) 0 mod 4. The number 5 100 5 is divisible by 3. Since 5 2 mod 3 and 25 1 mod 3, we compute modulo 3 as follows: 5 100 5 = 25 50 5 1 50 2 1 mod 3. n 2 + 6n + 9 0 mod (n + 3), for all positive integers n. Evaluating n 2 + 6n + 9 modulo n + 3, we get ( 3) 2 + 6( 3) + 9 = 0. There exists integers a, b, such that gcd(a, b) + lcm(a, b) = a + b. If a = b, then gcd(a, b) = lcm(a, b) = a = b, so their sum is a + b. 2

Problem 2 (26 points) Consider the boolean function f(p, q, r) defined as follows: f(p, q, r) = (p q) ( q r ( q r) ) (1) where q is the negation of q, and denotes the implication connective. a. The truth table for f(p, q, r) can be obtained by combining the truth tables of the various statement forms from which f(p, q, r) is composed, as follows: p q r p q q r q r q r ( q r) f(p, q, r) 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 b. To express the function f(p, q, r) in disjunctive normal form (DNF), we can simply read off the three corresponding minterms from the truth table, and obtain: f(p, q, r) = pqr pq r pqr (2) c. To derive a simple expression for f(p, q, r), we can start from (1) while taking into account the truth table constructed in part (a). The truth table shows that q r ( q r) takes the value 1 if and only if q = r = 1. Thus we can immediately recognize that q r ( q r) q r. Consequently, f(p, q, r) can be simplified as follows: f(p, q, r) = (p q) ( q r ( q r) ) = (p q) (q r) = q (p r) where we have also used the distributive rule. Alternatively, we can start with the DNF in (2) and simplify using the algebraic rules as follows: f(p, q, r) = pqr pq r pqr = pqr ( pq ( r r) ) = pqr pq = q ( pr p ) = q ( ( p p) (r p) ) = q (p r) where we have used the fact that distributes over to get from pr p to ( p p) (r p). In both cases, the resulting circuit is given by: p r q f(p, q, r) 3

Problem 3 (14 points) The numbers x = 71 9 and y = 121 3 are expressed in the nonary (base-9) and the ternary (base-3) number systems, respectively. a. Convert x = 71 9 into the ternary number system. Answer: Since 9 = 3 2, we can easily compute as follows: 71 9 = 7 9 1 + 1 9 0 = (2 3 + 1) 3 2 + 1 3 0 = 2 3 3 + 1 3 2 + 0 3 1 + 1 3 0 = 2101 3 x = 2101 3 b. Compute the sum a = x + y using ternary arithmetic. Show all stages of your ternary computation and express its results in the ternary number system. Answer: Here is the ternary computation: 2 1 0 1 + 1 2 1 2 2 2 2 a = 2222 3 c. Convert the sum a = x + y from part (b) into the nonary number system. Answer: Since 9 = 3 2, we can easily compute as follows: 2222 3 = 2 3 3 + 2 3 2 + 2 3 1 + 2 3 0 = (2 3 + 2) 3 2 + (2 3 + 2) 3 0 = 8 9 1 + 8 9 0 Problem 4 (30 points) a. Let p be an odd prime. What is the remainder when p 2 is divided by 8? a = 88 9 Answer: Write p = 2t + 1 for t 1. Then p 2 = (2t + 1) 2 = 4t 2 + 4t + 1 = 4t(t + 1) + 1. Clearly, one of t or t + 1 is even (and the other is odd). Hence t(t + 1) is always divisible by 2, and therefore 4t(t + 1) is always divisible by 8. It follows that p 2 1 mod 8. p 2 1 mod 8 b. Let n 2 be an integer, and suppose that a and b are positive integers such that a n + 1 (mod 2n) and b n 1 (mod n) Find the unique integer c in the range 0 c n 1 which satisfies c 2a + 3b (mod n). Answer: In order to find c, it is important to realize that modulo n, we have a 1 and b 1. Thus c 2a + 3b 2 3 1 (mod n). The unique integer c in the range 0 c n 1 which satisfies this is c = n 1. c = n 1 4

c. Prove that for all positive integers n, we have gcd(9n + 4, 3n + 1) = 1. Answer: Dividing 3n + 1 into 9n + 4 with remainder, we get 9n + 4 = 3(3n + 1) + 1. Thus we can run the Euclidean algorithm to compute gcd(9n + 4, 3n + 1) as follows: gcd(9n + 4, 3n + 1) = gcd(3n + 1, 1) = 1 Extra-credit Problem 5 (30 points) Alice and Bob, who are good friends, receive an invitation to a high-stakes game show called Live Rich or Die. The invitation letter specifies the rules of the game as follows: The two of you will enter the game room, each wearing either a black hat or a white hat. You will be the only people in the room. You cannot see or know the color of your own hat, but you can see the color of the hat the other person is wearing. Within a minute of entering the game room, each of you should write on a card what the color of your own hat is. You will simultaneously hand these cards to the host when exiting the room. While in the room, you cannot communicate with each other in any way. If at least one of you guessed the color of his or her own hat correctly, you will each receive $1,000,000 congratulations! However, if you are both wrong or if you attempt to violate these rules in any way, you will both die. Alice and Bob certainly would not risk dying, even if there is a tiny chance of this happening. However, they would not mind getting rich either. They also took CSE20 last year, so they know a thing or two about propositional logic, statement variables, truth tables, and boolean functions. What would you advise Alice and Bob to do? Can they get rich on this show, without any chance of dying? If so, how exactly? Or, maybe, there is always a chance that they will die. If so, why? Answer: Alice and Bob can get rich on this show as follows. Alice should write on her card the color that she sees (of Bob s hat), while Bob should write on his card the opposite of the color that he sees. That is, if Alice is wearing white, Bob should write black, whereas if Alice is wearing black, Bob should write white. Here is why this always works. Let x denote the color of Alice s hat, and let y denote the color of Bob s hat. Since Alice sees Bob s hat, what she writes on her card can be a function of y. Similarly, what Bob writes on his card can be a function of x. Let f(y) and g(x) denote these two boolean functions. There are 2 21 = 4 different boolean functions of one variable, which means there are 4 4 = 16 cases to consider, as follows: f(y) = W, B, y, ȳ and g(x) = W, B, x, x (3) It is possible to arrive at the solution by writing out the truth tables for these 16 cases. However, here is a shortcut. The assertion that Alice guesses the color of her hat correctly can be expressed as the biconditional f(y) x. Similarly, g(x) y is true if and only if Bob guesses the color of his hat correctly. Since it will suffice for one of them to guess the color of his or her hat, what we want is that ( f(y) x ) ( g(x) y ) x f(y) x f(y) yg(x) ȳg(x) (4) is a tautology. Comparing (4) with the DNF of the tautology function, namely xy xy xȳ xȳ, we see that setting f(y) = y and g(x) = x works. Setting f(y) = ȳ and g(x) = x also works. No other choice in (3) will work, as you can verify by writing down the truth tables. 5