Download as pdf or txt
Download as pdf or txt
You are on page 1of 104

CSE20 - Discrete Mathematics

Dr. Cynthia Bailey Lee Dr. Mia Minnes


csemoodle.ucsd.edu ted.ucsd.edu and www.math.ucsd.edu/~minnes/cse20 and minnes@math.ucsd.edu

iClicker frequency BB Reminder: Final exam will be 6/12/2013 11:30am - 2:29pm In this room

Minnes (CSE20)

6/7/2013

1 / 24

Todays topics
Reviewing for Final Exam
1

2 3 4 5 6 7 8 9 10 11

Propositions, propositional variables Logical connectives Truth tables Equivalence of propositions Valid argument forms Normal forms: DNF, CNF Predicate quantiers Paradoxes Complete logical connectives Direct proofs Generalizing from a generic particular
Minnes (CSE20)

12 13 14 15 16 17 18 19 20 21 22 23

Contrapositive proofs Proofs by cases Proof by contradiction Induction Graphs Sets Relations Equivalence relations Strong induction Reachability Big-O , big-, big- Hardware logic
6/7/2013 2 / 24

Reference table

Minnes (CSE20)

6/7/2013

3 / 24

Choose your own adventure:


Which examples would you like to see? A. for yes; B. for no Predicate Quantiers (2 questions) Logical equivalences (1 question) Proof techniques (2 questions) Proof by contradiction (2 questions) Sets and relations (2 questions) Strong induction (2 questions) Reachability (1 question) Big-O, Big-, Big- (1 question) Logic circuits and hardware (1 question) Number systems (2 questions)

Minnes (CSE20)

6/7/2013

4 / 24

Predicate Quantiers, Q1

In the domain of fruit, we use the predicate Love(x,y) to represent the sentence x loves y. Consider the two statements below: (I) y x .Love (x , y ) (II) x y .Love (x , y )

(a) Write the English translation of statement (I):

Minnes (CSE20)

6/7/2013

5 / 24

Predicate Quantiers, Q1

In the domain of fruit, we use the predicate Love(x,y) to represent the sentence x loves y. Consider the two statements below: (I) y x .Love (x , y ) (II) x y .Love (x , y )

(a) Write the English translation of statement (I): There is a fruit that no fruit loves.

Minnes (CSE20)

6/7/2013

5 / 24

Predicate Quantiers, Q1

In the domain of fruit, we use the predicate Love(x,y) to represent the sentence x loves y. Consider the two statements below: (I) y x .Love (x , y ) (II) x y .Love (x , y )

(b) Write the English translation of statement (II):

Minnes (CSE20)

6/7/2013

5 / 24

Predicate Quantiers, Q1

In the domain of fruit, we use the predicate Love(x,y) to represent the sentence x loves y. Consider the two statements below: (I) y x .Love (x , y ) (II) x y .Love (x , y )

(b) Write the English translation of statement (II): Each fruit loves some fruit.

Minnes (CSE20)

6/7/2013

5 / 24

Predicate Quantiers, Q1
In the domain of fruit, we use the predicate Love(x,y) to represent the sentence x loves y. Consider the two statements below: (I) y x .Love (x , y ) (II) x y .Love (x , y ) (c) In the diagram below, we represent the predicate P (x , y ) as an arrow from x to y . The diagram below currently shows that apple loves banana is true. Draw additional arrows in the diagram below to create a situation where BOTH of the above statements (I) and (II) are true of the diagram.

Minnes (CSE20)

6/7/2013

5 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (a) Write Every integer is either even or odd but not both in predicate logic. (b) Write the formal negation of your proposition from part (a).

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (a) Write Every integer is either even or odd but not both in predicate logic. x (x is even or odd but not both)

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (a) Write Every integer is either even or odd but not both in predicate logic. x ((L(x ) M (x )) (L(x ) M (x )))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x ((L(x ) M (x )) (L(x ) M (x )))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x ((L(x ) M (x )) (L(x ) M (x )))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x ((L(x ) M (x )) (L(x ) M (x )))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x ((L(x ) M (x ))(L(x ) M (x )))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x ((L(x ) M (x ))(L(x ) M (x )))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x (L(x )M (x )) (L(x ) M (x ))

Minnes (CSE20)

6/7/2013

6 / 24

Predicate Quantiers, Q2

In the domain of integers, consider the following predicates: L(x) = x is even M(x) = x is odd N(x,y,z) = x plus y is equal to z (b) Write the formal negation of your proposition from part (a). x (L(x ) M (x )) (L(x ) M (x )) There is an integer that is either both not even and not odd, or both even and odd.

Minnes (CSE20)

6/7/2013

6 / 24

Logical equivalences

Prove that (p q r ) (p (q r )) (q r ) (p (q r ))

Minnes (CSE20)

6/7/2013

7 / 24

Logical equivalences

Prove that (p q r ) (p (q r )) (q r ) (p (q r )) First approach: truth-table Recall that need to show that step-by-step truth table for (p q r ) (p (q r )) (q r ) (p (q r )) has all T in last column.

Minnes (CSE20)

6/7/2013

7 / 24

Logical equivalences
Prove that (p q r ) (p (q r )) (q r ) (p (q r )) First approach: truth-table Recall that need to show that step-by-step truth table for (p q r ) (p (q r )) (q r ) (p (q r )) has all T in last column.
p q r p z }| { p q r
A

qr

z }| { p (q r )

AB

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

7 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

z }| { p q r

qr

z }| { p (q r )

AB

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r

qr

z }| { p (q r )

AB

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr

z }| { p (q r )

AB

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr F T T T F T T T

z }| { p (q r )

AB

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr F T T T F T T T

z }| { p (q r ) F F F F F T T T

AB

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr F T T T F T T T

z }| { p (q r ) F F F F F T T T

AB F F F T F T T T

z }| { qr

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr F T T T F T T T

z }| { p (q r ) F F F F F T T T

AB F F F T F T T T

z }| { qr F F F T F F F T

C B

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr F T T T F T T T

z }| { p (q r ) F F F F F T T T

AB F F F T F T T T

z }| { qr F F F T F F F T

C B F F F T F T T T

(A B ) (C B )

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

p F F F F T T T T

q F F T T F F T T

r F T F T F T F T

p T T T T F F F F

z }| { p q r F F F T F F F F

qr F T T T F T T T

z }| { p (q r ) F F F F F T T T

AB F F F T F T T T

z }| { qr F F F T F F F T

C B F F F T F T T T

(A B ) (C B ) T T T T T T T T

Minnes (CSE20)

6/7/2013

8 / 24

Logical equivalences, contd

Prove that (p q r ) (p (q r )) (q r ) (p (q r )) Second approach: table of logical equivalences and valid argument forms (p q r ) (p (q r )) (q r ) (p (q r )) LHS . . . use Distributivity, commutativity, universal bound . . .

Minnes (CSE20)

6/7/2013

9 / 24

Proof techniques

To prove the theorem blah BLAH By direct proof: *A. Assume blah B. Assume BLAH C. Assume not blah D. Assume not BLAH E. None of the above. WTS BLAH WTS blah WTS not BLAH WTS not blah

Minnes (CSE20)

6/7/2013

10 / 24

Proof techniques

To prove the theorem blah BLAH By contrapositive proof: A. Assume blah B. Assume BLAH C. Assume not blah *D. Assume not BLAH E. None of the above. WTS BLAH WTS blah WTS not BLAH WTS not blah

Minnes (CSE20)

6/7/2013

10 / 24

Proof techniques

To prove the theorem blah BLAH By contradiction: A. Assume blah B. Assume BLAH C. Assume not blah D. Assume not BLAH *E. None of the above. WTS BLAH WTS blah WTS not BLAH WTS not blah

Minnes (CSE20)

6/7/2013

10 / 24

Proofs, Q2

Prove the theorem: For any integer, x , if x 2 6x + 5 is even then x is odd. Any step that relies on something other than basic algebra must be justied/proved as part of your proof.

Minnes (CSE20)

6/7/2013

11 / 24

Proofs, Q2

Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. Proof:

Minnes (CSE20)

6/7/2013

12 / 24

Proofs, Q2

Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. x (E (x 2 6x + 5) O (x )) Proof: Domain: integers

Minnes (CSE20)

6/7/2013

12 / 24

Proofs, Q2

Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. x (E (x 2 6x + 5) O (x )) Proof:


Let x be an integer. Generalizing from generic particular WTS: if x 2 6x + 5 is even then x is odd

Domain: integers

Minnes (CSE20)

6/7/2013

12 / 24

Proofs, Q2

Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. x (E (x 2 6x + 5) O (x )) Proof:


Let x be an integer. Generalizing from generic particular WTS: if x 2 6x + 5 is even then x is odd Assume (for contrapositve) : WTS (for contrapositive) :

Domain: integers

Minnes (CSE20)

6/7/2013

12 / 24

Proofs, Q2

Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. x (E (x 2 6x + 5) O (x )) Proof:


Let x be an integer. Generalizing from generic particular WTS: if x 2 6x + 5 is even then x is odd Assume (for contrapositve) : x is even WTS (for contrapositive) : x 2 6x + 5 is odd

Domain: integers

Minnes (CSE20)

6/7/2013

12 / 24

Proofs, Q2
Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. x (E (x 2 6x + 5) O (x )) Proof:
Let x be an integer. Generalizing from generic particular WTS: if x 2 6x + 5 is even then x is odd Assume (for contrapositve) : x is even WTS (for contrapositive) : x 2 6x + 5 is odd Body of the proof: By denition of even, there is an integer a such that x = 2a Multiplying and factoring: x 2 6x + 5 = (2a)2 6(2a) + 5 = 2(2a2 6a) + 5 = 2(2a2 6a + 2) + 1 Since 2a2 6a + 2 is an integer (integers are closed under addition, subtraction, and multiplication), we conclude that x 2 6x + 5 is an odd number, yay!.
Minnes (CSE20) 6/7/2013 12 / 24

Domain: integers

Proofs, Q2
Thm. For any integer, x , if x 2 6x + 5 is even then x is odd. x (E (x 2 6x + 5) O (x )) Proof:
Let x be an integer. Generalizing from generic particular WTS: if x 2 6x + 5 is even then x is odd Assume (for contrapositve) : x is even WTS (for contrapositive) : x 2 6x + 5 is odd Body of the proof: By denition of even, there is an integer a such that x = 2a Multiplying and factoring: x 2 6x + 5 = (2a)2 6(2a) + 5 = 2(2a2 6a) + 5 = 2(2a2 6a + 2) + 1 Since 2a2 6a + 2 is an integer (integers are closed under addition, subtraction, and multiplication), we conclude that x 2 6x + 5 is an odd number, yay!. Conclusion, therefore, for any integers x , if x 2 6x + 5 is even then x is odd QED.
Minnes (CSE20) 6/7/2013 12 / 24

Domain: integers

Proof by contradiction

To prove the theorem The product of two rational numbers is rational by contradiction, the assumption that we made (towards a contradiction) is A. x y (Q (x ) Q (y ) Q (xy )) B. x y (Q (x ) Q (y ) Q (xy )) C. x y (Q (x ) Q (y ) Q (xy )) *D. x y (Q (x ) Q (y ) Q (xy )) E. x y (Q (x ) Q (y ) Q (xy ))

Minnes (CSE20)

6/7/2013

13 / 24

Proof by contradiction, Q2

Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction)

Minnes (CSE20)

6/7/2013

14 / 24

Proof by contradiction, Q2

Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . .
We need to negate the whole theorem. That is, a, b N(a2 b 2 = 1). But we need to bring the negation inside . . .

a, b N(a2 b 2 = 1).

Minnes (CSE20)

6/7/2013

14 / 24

Proof by contradiction, Q2

Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement.

Minnes (CSE20)

6/7/2013

14 / 24

Proof by contradiction, Q2

Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement. Then a, b are positive integers and a2 b 2 = 1.

Minnes (CSE20)

6/7/2013

14 / 24

Proof by contradiction, Q2

Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement. Then a, b are positive integers and a2 b 2 = 1. We factor the LHS: But a + b , a b Z. (a + b )(a b ) = a2 b 2 = 1. Notice that the only integer factors of 1 are 1, 1 .

Minnes (CSE20)

6/7/2013

14 / 24

Proof by contradiction, Q2
Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement. Then a, b are positive integers and a2 b 2 = 1. We factor the LHS: But a + b , a b Z. Therefore, either a + b = a b = 1 or a + b = a b = 1. (a + b )(a b ) = a2 b 2 = 1. Notice that the only integer factors of 1 are 1, 1 .

Minnes (CSE20)

6/7/2013

14 / 24

Proof by contradiction, Q2
Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement. Then a, b are positive integers and a2 b 2 = 1. We factor the LHS: (a + b )(a b ) = a2 b 2 = 1. Notice that the only integer factors of 1 are 1, 1 . But a + b , a b Z. Therefore, either a + b = a b = 1 or a + b = a b = 1. In the rst case, a = b + 1 so a + b = b + 1 + b = 2b + 1 = 1 so b = 0. But, then, its not a positive integer, contradicting our assumption. In the second case,
Minnes (CSE20) 6/7/2013 14 / 24

Proof by contradiction, Q2
Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement. Then a, b are positive integers and a2 b 2 = 1. We factor the LHS: (a + b )(a b ) = a2 b 2 = 1. Notice that the only integer factors of 1 are 1, 1 . But a + b , a b Z. Therefore, either a + b = a b = 1 or a + b = a b = 1. In the rst case, . . . contradicting our assumption. In the second case, a = b 1 so a + b = b 1 + b = 2b 1 = 1, so b = 0. But, then, its not a positive integer, contradicting our assumption.
Minnes (CSE20) 6/7/2013 14 / 24

Proof by contradiction, Q2
Theorem. There are no positive integer solutions to the diophantine equation x 2 y 2 = 1. Proof: (by contradiction) Assume, for a contradiction, that . . . a, b N(a2 b 2 = 1). We need to deduce from this a contradiction. Let a, b witness the existential statement. Then a, b are positive integers and a2 b 2 = 1. We factor the LHS: (a + b )(a b ) = a2 b 2 = 1. Notice that the only integer factors of 1 are 1, 1 . But a + b , a b Z. Therefore, either a + b = a b = 1 or a + b = a b = 1. In the rst case, . . . contradicting our assumption. In the second case, . . . contradicting our assumption. Thus, we get a contradiction. We conclude that there are no positive integer solutions to x 2 y 2 = 1. QED
Minnes (CSE20) 6/7/2013 14 / 24

Sets, Q1

The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. None of the prime numbers are multiples of 12.

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1
The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. None of the prime numbers are multiples of 12. B D =

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1

The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. All multiples of 12 are also multiples of 3.

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1
The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. All multiples of 12 are also multiples of 3. DC

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1

The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. There are odd primes.

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1
The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. There are odd primes. A B =

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1

The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. All the multiples of twelve are even and not prime.

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1
The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. All the multiples of twelve are even and not prime. D AB

Minnes (CSE20)

6/7/2013

15 / 24

Sets, Q1
The universal set for this problem is N = {x Z : x > 0}. Consider the following sets. A = The set of all even numbers. B = The set of all prime numbers. C = The set of all multiples of 3. D = The set of all multiples of 12. Using only the symbols A, B , C , D , N, , , =, =, , , , , (, and ), write the following statements in set notation. Bonus: Prove D C . Prove C B .

Minnes (CSE20)

6/7/2013

15 / 24

Sets and relations

Let U be a xed nite set with at least two elements. Consider the relation R on S = P (U ) given by R (X , Y ) if and only if X Y.

A. R is reexive, symmetric, and transitive. *B. R is reexive and transitive; R is not symmetric. C. R is symmetric and transitive; R is not reexive. D. R is reexive and symmetric; R is not transitive. E. None of the above.

Minnes (CSE20)

6/7/2013

16 / 24

Strong induction, Example 1


Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n .

Minnes (CSE20)

6/7/2013

17 / 24

Strong induction, Example 1


Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Before we prove the theorem, lets write out the rst few terms of the sequence: A. 1, 2, 3, 4, 5, 6, B. 1, 2, 3, 5, 8, 13 *C. 1, 2, 3, 6, 11, 20 D. 1, 2, 3, 7, 15, 31 E. None of the above

Minnes (CSE20)

6/7/2013

17 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step:

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: WTS a1 < 21 and a2 < 22 and a3 < 23

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: WTS a1 < 21 and a2 < 22 and a3 < 23

By denition, a1 = 1 and 21 = 2. Thus, since 1 < 2, a1 < 21 By denition, a2 = 2 and 22 = 4. Thus, since 2 < 4, a2 < 22 By denition, a3 = 3 and 23 = 8. Thus, since 3 < 8, a3 < 23

. . .

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.
Assume WTS

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.

Assume a1 < 21 , a2 < 22 , a3 < 23 , . . . , an < 2n WTS an+1 < 2n+1

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)

Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.

Assume a1 < 21 , a2 < 22 , a3 < 23 , . . . , an < 2n WTS an+1 < 2n+1 Since n 3, adding 1 to each side gives that n + 1 4. Therefore, the denition of an+1 is an+1 = an + an1 + an2 .

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)


Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.

Assume a1 < 21 , a2 < 22 , a3 < 23 , . . . , an < 2n WTS an+1 < 2n+1 Since n 3, adding 1 to each side gives that n + 1 4. Therefore, the denition of an+1 is an+1 = an + an1 + an2 . Applying the induction assumption (to an , an1 , an2 ), an+1 < 2n + 2n1 + 2n2 .

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)


Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4 Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.

Assume a1 < 21 , a2 < 22 , a3 < 23 , . . . , an < 2n WTS an+1 < 2n+1 Since n 3, adding 1 to each side gives that n + 1 4. Therefore, the denition of an+1 is an+1 = an + an1 + an2 . Applying the induction assumption (to an , an1 , an2 ), an+1 < 2n + 2n1 + 2n2 . Factoring the RHS of the inequality: an+1 < 2n2 (22 + 21 + 1) = 2n2 (4 + 2 + 1) = 2n2 (7)

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)


Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4 Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.

Assume a1 < 21 , a2 < 22 , a3 < 23 , . . . , an < 2n WTS an+1 < 2n+1 Since n 3, adding 1 to each side gives that n + 1 4. Therefore, the denition of an+1 is an+1 = an + an1 + an2 . Applying the induction assumption (to an , an1 , an2 ), an+1 < 2n + 2n1 + 2n2 . Factoring the RHS of the inequality: an+1 < 2n2 (22 + 21 + 1) = 2n2 (4 + 2 + 1) = 2n2 (7) < 2n2 8 = 2n2 23 = 2n+1

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 1 (contd)


Consider the sequence a1 , a2 , a3 , . . . dened by a1 = 1, a2 = 2, a3 = 3, an = an1 + an2 + an3 if n 4

Theorem. For all integers n 1, an < 2n . Proof. By strong induction on n Base step: a1 < 21 and a2 < 22 and a3 < 23 Induction step: Let n 3.

Assume a1 < 21 , a2 < 22 , a3 < 23 , . . . , an < 2n WTS an+1 < 2n+1

Thus, the induction holds and we have proved that for all n 1, an < 2n QED

Minnes (CSE20)

6/7/2013

18 / 24

Strong induction, Example 2: (5/22 lecture)


Consider the sequence dened recursively as 9 10 d2 = , ... dk = (dk 1 )(dk 2 ) for integers k 3. d1 = , 10 11 Theorem: For all positive integers n, 0 < dn < 1. Proof: (by strong mathematical induction)
Base step: WTS [P (a)] . . ., as required for the base step. Induction step: Let n be [an arbitrary element in the domain]
Assume [k n P (k )] WTS [P (n + 1)] ... So the induction holds.

Conclusion, for all integers n greater than or equal to a, P (n), QED.

What is base step value, a? A. 0 *B. 1


Minnes (CSE20)

C. 2 D. n
6/7/2013 19 / 24

Strong induction, Example 2: (5/22 lecture)


Consider the sequence dened recursively as d1 = 9 , 10 d2 = 10 , 11 ... dk = (dk 1 )(dk 2 ) for integers k 3.

Theorem: For all positive integers n, 0 < dn < 1. Proof: (by strong mathematical induction)
Base step: WTS 0 < d1 < 1 and 0 < d2 < 1 Note 2 base steps! Induction step: Let n be a positive integer
Assume for each k such that 0 < k n, we have 0 < dk < 1 WTS 0 < dn+1 < 1 ... So the induction holds.

Conclusion, for all positive integers n, 0 < dn < 1. QED.

Minnes (CSE20)

6/7/2013

19 / 24

Strong induction, Example 2: (5/22 lecture)

Consider the sequence dened recursively as d1 = 9 , 10 d2 = 10 , 11 ... dk = (dk 1 )(dk 2 ) for integers k 3.

Theorem: For all positive integers n, 0 < dn < 1. Proof: (by strong mathematical induction)
By denition d1 =
9 10

Base step: WTS 0 < d1 < 1 and 0 < d2 < 1


= 0.9 and d2 =
10 11

= 0.909..

These real numbers are strictly between 0 and 1

Induction step: . . . Conclusion, for all positive integers n, 0 < dn < 1. QED.

Minnes (CSE20)

6/7/2013

19 / 24

Strong induction, Example 2: (5/22 lecture)

Consider the sequence dened recursively as d1 = 9 , 10 d2 = 10 , 11 ... dk = (dk 1 )(dk 2 ) for integers k 3.

Theorem: For all positive integers n, 0 < dn < 1. Proof: (by strong mathematical induction)
Base step: WTS 0 < d1 < 1 and 0 < d2 < 1 . . . Induction step: Let n be a positive integer.
Assume for each k such that 0 < k n, we have 0 < dk < 1 WTS 0 < dn+1 < 1,

Conclusion, for all positive integers n, 0 < dn < 1. QED.

Minnes (CSE20)

6/7/2013

19 / 24

Strong induction, Example 2: (5/22 lecture)


Consider the sequence dened recursively as 9 10 d2 = , ... dk = (dk 1 )(dk 2 ) for integers k 3. d1 = , 10 11 Theorem: For all positive integers n, 0 < dn < 1. Proof: (by strong mathematical induction)
Base step: WTS 0 < d1 < 1 and 0 < d2 < 1 . . . Induction step: Let n be a positive integer.
Assume for each k such that 0 < k n, we have 0 < dk < 1 WTS 0 < dn+1 < 1, If n + 1 = 2, then base step takes care of it. Otherwise, n + 1 2 and n 1 > 0. By denition, dn+1 = dn dn1 . Since both n, n 1 are positive integers, the induction assumption gives that 0 < dn1 < 1. 0 < dn < 1 The product of two positive numbers is positive. Therefore 0 < dn dn1 . The product of two positive numbers less than 1 is less than 1. Therefore, dn dn1 < 1, as required.
6/7/2013 19 / 24

Conclusion, for all positive integers n, 0 < dn < 1. QED.


Minnes (CSE20)

Reachability
Consider the graph below
D C E I J K

B A

H G

What is the set of nodes that are reachable from K ? A. B. {I , K , L} *C. {G , I , K , L} D. {I , L} E. None of the above.
Minnes (CSE20) 6/7/2013 20 / 24

Reachability
Consider the graph below
D C E I J K

B A

H G

What is the Boundary set after one iteration of the while loop in the Reachability algorithm on this graph with Source = K A. B. C. *D. E. {I , K , L} {G , I , K , L} {I , L} None of the above.
Minnes (CSE20) 6/7/2013 20 / 24

and

Target = H ?

Big-O, Big-, Big-


Which of these functions are in O (n3 )?

g1 (n) = n4 A. g1 *B. g2 , g3 C. g1 , g2 D. g3 E. None of the above.


Minnes (CSE20)

g2 (n) = 20n

g3 (n) = log2 (n17 )

6/7/2013

21 / 24

Big-O, Big-, Big-


Which of these functions are in (n3 )?

g1 (n) = n4 A. g1 B. g2 , g3 C. g1 , g2 D. g3 *E. None of the above.


Minnes (CSE20)

g2 (n) = 20n

g3 (n) = log2 (n17 )

6/7/2013

21 / 24

Big-O, Big-, Big-


Which of these functions are in (n3 )? g1 (n) = n4 *A. g1 B. g2 , g3 C. g1 , g2 D. g3 E. None of the above. g3 (n) = log2 (n17 )

g2 (n) = 20n

Minnes (CSE20)

6/7/2013

21 / 24

Logic circuits and hardware

What are the inputs to this logic gate? *A. A, B, C B. A, C C. B, C, Q D. A, B, C, D, E, Q E. None of the above
Minnes (CSE20) 6/7/2013 22 / 24

Logic circuits and hardware

What logical proposition describes Q ? A. (A B ) C B. (A B ) (B C ) *C. (A B ) (B C ) D. (A B ) (B C ) E. None of the above


Minnes (CSE20) 6/7/2013 22 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8.

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Translating: Write | 5| in binary: Insert additional 0 in front: Flip all bits: Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Translating: Write | 5| in binary: 5 d = 101 b Insert additional 0 in front: Flip all bits: Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Translating: Write | 5| in binary: 5 d = 101 b Insert additional 0 in front: 0101 Flip all bits: Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Translating: Write | 5| in binary: 5 d = 101 b Insert additional 0 in front: 0101 Flip all bits: 1010 Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Translating: Write | 5| in binary: 5 d = 101 b Insert additional 0 in front: 0101 Flip all bits: 1010 Add 1: 1011

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Translating: Write | 3| in binary: 3 d = 11 b Insert additional 0 in front: Flip all bits: Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Translating: Write | 3| in binary: 3 d = 11 b Insert additional 0 in front: 011 Flip all bits: Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Translating: Write | 3| in binary: 3 d = 11 b Insert additional 0 in front: 011 Flip all bits: 100 Add 1:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Translating: Write | 3| in binary: 3 d = 11 b Insert additional 0 in front: 011 Flip all bits: 100 Add 1: 101

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Twos complement representation of 3 is 101.

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1

Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Twos complement representation of 3 is 101. Adding the two numbers we get from the twos complement representation:

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1


Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Twos complement representation of 3 is 101. Adding the two numbers we get from the twos complement representation: First, pad shorter number so theyre the same length. 101 becomes 1101. 1011 +1101

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1


Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Twos complement representation of 3 is 101. Adding the two numbers we get from the twos complement representation: First, pad shorter number so theyre the same length. 101 becomes 1101. 1011 +1101 11000

Minnes (CSE20)

6/7/2013

23 / 24

Number systems, Example 1


Compute (5) + (3) using twos complement binary representation, and conrm that the answer has value 8. Twos complement representation of 5 is 1011. Twos complement representation of 3 is 101. Adding the two numbers we get from the twos complement representation: First, pad shorter number so theyre the same length. 101 becomes 1101. 1011 +1101 11000 Converting result to decimal: 11000 b = 24 + 23 + 0 22 + 0 21 + 0 20 = 16 + 8 = 8
Minnes (CSE20) 6/7/2013 23 / 24

Number systems, Example 2

Which of these represent the same (positive) number? A. 14 d , 0xF , 1110 b B. 11 d , 0x 11, 1011 b C. 10 d , 0xA, 10100 b D. 25 d , 0x 19, 11011 b *E. 20 d , 0x 14, 10100 b

Minnes (CSE20)

6/7/2013

24 / 24

You might also like