CSE 20: Discrete Mathematics

Similar documents
3 The fundamentals: Algorithms, the integers, and matrices

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

4 Number Theory and Cryptography

Conversions between Decimal and Binary

CSE 20 DISCRETE MATH. Winter

Part I, Number Systems. CS131 Mathematics for Computer Scientists II Note 1 INTEGERS

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

2x 1 7. A linear congruence in modular arithmetic is an equation of the form. Why is the solution a set of integers rather than a unique integer?

CHAPTER 3. Congruences. Congruence: definitions and properties

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

Mathematical Foundations of Cryptography

CSE 20 DISCRETE MATH. Fall

CSE 20 DISCRETE MATH. Fall

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

NUMBERS AND CODES CHAPTER Numbers

An integer p is prime if p > 1 and p has exactly two positive divisors, 1 and p.

MATH 361: NUMBER THEORY FOURTH LECTURE

Integers and Division

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Part V. Chapter 19. Congruence of integers

MATH 433 Applied Algebra Lecture 4: Modular arithmetic (continued). Linear congruences.

Applied Cryptography and Computer Security CSE 664 Spring 2017

Finite Fields. Mike Reiter

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Basic elements of number theory

Basic elements of number theory

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

Course MA2C02, Hilary Term 2013 Section 9: Introduction to Number Theory and Cryptography

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

COMPUTER ARITHMETIC. 13/05/2010 cryptography - math background pp. 1 / 162

Today. Polynomials. Secret Sharing.

4. Congruence Classes

With Question/Answer Animations. Chapter 4

CHAPTER 6. Prime Numbers. Definition and Fundamental Results

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

Polynomials. Chapter 4

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

7.2 Applications of Euler s and Fermat s Theorem.

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

Chapter 5. Number Theory. 5.1 Base b representations

Math 109 HW 9 Solutions

Course 2BA1: Trinity 2006 Section 9: Introduction to Number Theory and Cryptography

7. Prime Numbers Part VI of PJE

For your quiz in recitation this week, refer to these exercise generators:

SEVENTH EDITION and EXPANDED SEVENTH EDITION

MAT246H1S - Concepts In Abstract Mathematics. Solutions to Term Test 1 - February 1, 2018

Linear Cyclic Codes. Polynomial Word 1 + x + x x 4 + x 5 + x x + x f(x) = q(x)h(x) + r(x),

Commutative Rings and Fields

Mathematical Induction

hexadecimal-to-decimal conversion

Algorithms: Review from last time

Chapter 4 Finite Fields

MATH Fundamental Concepts of Algebra

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Remainders. We learned how to multiply and divide in elementary

CS483 Design and Analysis of Algorithms

We say that the base of the decimal number system is ten, represented by the symbol

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 8

Linear Cyclic Codes. Polynomial Word 1 + x + x x 4 + x 5 + x x + x

The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.

Ch 7 Summary - POLYNOMIAL FUNCTIONS

Chapter 1 : The language of mathematics.

Lecture 6: Introducing Complexity

Chapter 3: Polynomial and Rational Functions

Encryption: The RSA Public Key Cipher

CHAPTER 2 NUMBER SYSTEMS

INTEGERS. In this section we aim to show the following: Goal. Every natural number can be written uniquely as a product of primes.

MATH 115, SUMMER 2012 LECTURE 4 THURSDAY, JUNE 21ST

Discrete Mathematics GCD, LCM, RSA Algorithm

1 Overview and revision

ENGIN 112 Intro to Electrical and Computer Engineering

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Note 7

Notes on Systems of Linear Congruences

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. February 9, :30 pm Duration: 1:50 hs. Closed book, no calculators

NOTES ON SIMPLE NUMBER THEORY

Math 131 notes. Jason Riedy. 6 October, Linear Diophantine equations : Likely delayed 6

Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

a the relation arb is defined if and only if = 2 k, k

Notes on arithmetic. 1. Representation in base B

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

L1 2.1 Long Division of Polynomials and The Remainder Theorem Lesson MHF4U Jensen

Solving the general quadratic congruence. y 2 Δ (mod p),

Computer Architecture 10. Residue Number Systems

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

ICS141: Discrete Mathematics for Computer Science I

ECEN 5022 Cryptography

CSE 20 DISCRETE MATH. Winter

Definition 6.1 (p.277) A positive integer n is prime when n > 1 and the only positive divisors are 1 and n. Alternatively

Fault Tolerance & Reliability CDA Chapter 2 Cyclic Polynomial Codes

CPSC 467: Cryptography and Computer Security

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

WORKSHEET MATH 215, FALL 15, WHYTE. We begin our course with the natural numbers:

Math 13, Spring 2013, Lecture B: Midterm

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications

M381 Number Theory 2004 Page 1

Long division for integers

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

Transcription:

Spring 2018

Summary So far: Today: Logic and proofs Divisibility, modular arithmetics Number Systems More logic definitions and proofs Reading: All of Chap. 1 + Chap 4.1, 4.2.

Divisibility P = 5 divides 30 Q = 8 divides 10 R = 4 divides 2 Questions: Propositions P,Q,R are (A) T,T,T; (B) T,F,F; (C) F,T,F; (D) F,F,F

Divisibility P = 5 divides 30 Q = 8 divides 10 R = 4 divides 2 Questions: Propositions P,Q,R are (A) T,T,T; (B) T,F,F; (C) F,T,F; (D) F,F,F Definition An integer a divides an integer b (written a b), if there is an integer c such that (A) a = b c; (B) a b = c; (C) b/a = c; (D) b = a c;

Divisibility P = 5 divides 30 Q = 8 divides 10 R = 4 divides 2 Questions: Propositions P,Q,R are (A) T,T,T; (B) T,F,F; (C) F,T,F; (D) F,F,F Definition An integer a divides an integer b (written a b), if there is an integer c such that (A) a = b c; (B) a b = c; (C) b/a = c; (D) b = a c; Answer (D): (a b) c.b = a c. We also say that b is a multiple of a.

Transitivity Definition A binary relation R(x, y) is transitive if x, y, z.r(x, y) R(y, z) R(x, z). Questions: Is relation D(a, b) = (a b) transitive? (A) Yes; (B) No; (C) I don t know

Transitivity Definition A binary relation R(x, y) is transitive if x, y, z.r(x, y) R(y, z) R(x, z). Questions: Is relation D(a, b) = (a b) transitive? (A) Yes; (B) No; (C) I don t know Yes, it is transitive. In English: If x divides y, and y divides z, then x divides z.

Proving Transitivity of Theorem The divisibility relation D(a, b) = (a b) is transitive.

Proving Transitivity of Theorem The divisibility relation D(a, b) = (a b) is transitive. Proof We want to prove that for all integers a, b, c, if (x y) and (y z), then (x z). Let x, y, z be arbitrary integers Assume that (x y) and (y z). By definition, there exist an integer c such that y = cx an integer d such that z = dy It follows that there exists an integer b = dc such that So, x z. z = dy = d(cx) = (dc)x = bx.

Congruence Definition Two integers a, b are congruent modulo an integer m (written a m b) if m divides (a b). (a m b) m (a b) q.q m = a b Question: For what values of m 1 is the relation m transitive? (A) all m > 1; (B) all m 1; (C) all even m; (D) only for m = 2

Transitivity of m Theorem: For any integers a, b, c and positive integer m, if a m b and b m c, then a m c. Proof:

Transitivity of m Theorem: For any integers a, b, c and positive integer m, if a m b and b m c, then a m c. Proof: 1. Let m, a, b, c be arbitrary integers, with m 1. 2. Assume a m b and b m c 3. By definition, there exist integers x, y such that mx = a b and my = b c 4. Adding up the last two equations gives mx + my = (a b) + (b c) = a c 5. Therefore, mz = a c for z = x + y. 6. This proves that a m c

Division Theorem Theorem (Division Theorem) For any integer a and positive integer b > 0 there exists a (unique) pair of integers (q, r) such that a = qb + r and 0 r < b. Vocabulary: a: dividend; b: divisor; q: quotient; r: reminder.

Division Theorem Theorem (Division Theorem) For any integer a and positive integer b > 0 there exists a (unique) pair of integers (q, r) such that a = qb + r and 0 r < b. Vocabulary: a: dividend; b: divisor; q: quotient; r: reminder. Question: What is the result (q, r) of division with remainder of a = 24 by b = 7? (A) q = 3, r = 5; (B) q = 4, r = 4; (C) q = 2, r = 3; (D) q = 3, r = 3

Uniqueness A new quantifier: There exists a unique x such that P(x) Think of P as an equation. A solution to P(x) is a value of x such that P(x) is true. What we are saying is that P(x) has precisely one solution Sometimes this is denoted!x.p(x) Can we express!x.p(x) using the standard quantifiers?

Uniqueness A new quantifier: There exists a unique x such that P(x) Think of P as an equation. A solution to P(x) is a value of x such that P(x) is true. What we are saying is that P(x) has precisely one solution Sometimes this is denoted!x.p(x) Can we express!x.p(x) using the standard quantifiers? x.(p(x) U(x)) where U(x) = P(x) has no other solution beside x U(x) = y.(p(y) (x = y))!x.p(x) x.(p(x) y.(p(y) (x = y))).

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b.

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b. Therefore (q q )b = r r, and r r < b.

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b. Therefore (q q )b = r r, and r r < b. We first prove that q = q.

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b. Therefore (q q )b = r r, and r r < b. We first prove that q = q. Assume for contradiction that q q

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b. Therefore (q q )b = r r, and r r < b. We first prove that q = q. Assume for contradiction that q q Then r r = q q b b, contradicting r r < b.

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b. Therefore (q q )b = r r, and r r < b. We first prove that q = q. Assume for contradiction that q q Then r r = q q b b, contradicting r r < b. Since q = q, we also have r r = (q q )b = 0.

Proving Uniqueness Theorem The result (q, r) of division with remainder is unique Proof Let a, b be arbitrary integers, with b > 0, and let (q, r) be a solution of the division with remainder of a, b. Let (q, r ) be another solution. We need to prove that (q, r) = (q, r ). By definition, qb + r = q b + r = a and 0 r, r < b. Therefore (q q )b = r r, and r r < b. We first prove that q = q. Assume for contradiction that q q Then r r = q q b b, contradicting r r < b. Since q = q, we also have r r = (q q )b = 0. This proves that r = r and (q, r ) = (q, r) is unique.

Division Theorem (Application 1) Let (q, r) the result of the division with remainder of a by m. The uniqueness part of the theorem tell us that (q, r) are well defined We may think of divrem(a,b) = (q,r) as an algorithm In may applications we are interested only in r = a mod m. (a%m in some programming languages.) Theorem: For any integers a, b and positive integer m (modulus), a m b if and only if (a mod m) = (b mod m). Applications: Hashing, modular arithmetics, cryptography. 64-bit computer: Each 64-bit register stores a value between 0 and m = 2 64 1 All arithmetic operations are defined modulo m = 2 64

Division Theorem (Application 2) Every integer is either even or odd, but not both. Theorem: n.e(n) O(n). Proof: 1. Let n be an arbitrary integer 2. Divide n by 2. By the division theorem, there are integers (q, r) such that n = 2q + r and 0 r < 2 3. So, it must be r = 0 or r = 1. 4. If r = 0, then n = 2q, and n is even. 5. If r = 1, then n = 2q + 1, and n is odd. 6. n cannot be simultaneously even and odd because (q, r) is unique.

Modular Addition Theorem: If a 1 m b 1 and a 2 m b 2, then (a 1 + a 2 ) m (b 1 + b 2 ). Corollary: (a 1 + a 2 ) mod m = ((a 1 mod m) + (a 2 mod m)) mod m We can define a modular addition operation a + m b = (a + b) mod m, which operates on numbers a, b in Z m = {0,..., m 1}.

Modular Addition Theorem: If a 1 m b 1 and a 2 m b 2, then (a 1 + a 2 ) m (b 1 + b 2 ). Corollary: (a 1 + a 2 ) mod m = ((a 1 mod m) + (a 2 mod m)) mod m We can define a modular addition operation a + m b = (a + b) mod m, which operates on numbers a, b in Z m = {0,..., m 1}. Special case for m = 2: Z 2 = {0, 1} a mod 2 = 0 Even(a) a mod 2 = 1 Odd(a) Addition Table: a + 2 b b=0 b=1 a=0 0 1 a=1 1 0 Familiar rules: even +even = even even + odd = odd odd+odd = even

Modular Multiplication Theorem: If a 1 m b 1 and a 2 m b 2, then (a 1 a 2 ) m (b 1 b 2 ). Corollary: (a 1 a 2 ) mod m = ((a 1 mod m) (a 2 mod m)) mod m We can define a modular multiplication operation a m b = (a b) mod m, which operates on numbers a, b in Z m = {0,..., m 1}.

Modular Multiplication Theorem: If a 1 m b 1 and a 2 m b 2, then (a 1 a 2 ) m (b 1 b 2 ). Corollary: (a 1 a 2 ) mod m = ((a 1 mod m) (a 2 mod m)) mod m We can define a modular multiplication operation a m b = (a b) mod m, which operates on numbers a, b in Z m = {0,..., m 1}. Special case for m = 2: Z 2 = {0, 1} a mod 2 = 0 Even(a) a mod 2 = 1 Odd(a) Addition Table: a 2 b b=0 b=1 a=0 0 0 a=1 0 1 Familiar rules: even times even = even even times odd = even odd times odd = odd

Decimal notation Standard decimal notation: 1832 = 1 10 3 + 8 10 2 + 3 10 1 + 2 10 0 Every positive integer can be written (uniquely) as a sequence of digits n = c k c k 1... c 1 c 0 where each c i is one of 0, 1,..., 9. n = k i=0 10 i c i = c 0 + 10c 1 + 10 2 c 2 + 10 3 c 3 + 10 k c k where 0 c i < 10.

Decimal notation Standard decimal notation: 1832 = 1 10 3 + 8 10 2 + 3 10 1 + 2 10 0 Every positive integer can be written (uniquely) as a sequence of digits n = c k c k 1... c 1 c 0 where each c i is one of 0, 1,..., 9. n = k i=0 10 i c i = c 0 + 10c 1 + 10 2 c 2 + 10 3 c 3 + 10 k c k where 0 c i < 10. What is the last digit c 0 of n? (A) n mod 10 ; (B) n/10; (C) n 10; (D) I don t know.

Decimal notation Standard decimal notation: 1832 = 1 10 3 + 8 10 2 + 3 10 1 + 2 10 0 Every positive integer can be written (uniquely) as a sequence of digits n = c k c k 1... c 1 c 0 where each c i is one of 0, 1,..., 9. n = k i=0 10 i c i = c 0 + 10c 1 + 10 2 c 2 + 10 3 c 3 + 10 k c k where 0 c i < 10. What is the last digit c 0 of n? (A) n mod 10 ; (B) n/10; (C) n 10; (D) I don t know. For any integer n, the integer n (n mod 10) is always (A) positive; (B) a multiple of 10; (C) less than 10 (D) none.

Decimal notation If c k c k 1..., c 1, c 0 is the decimal representation of n. Then, the number represented by the digits c k c k 1..., c 2, c 1 equals (A) n (n mod 10); (B) n 10; (C) (n (n mod 10))/10; (D) n mod 10

Decimal notation If c k c k 1..., c 1, c 0 is the decimal representation of n. Then, the number represented by the digits c k c k 1..., c 2, c 1 equals (A) n (n mod 10); (B) n 10; (C) (n (n mod 10))/10; (D) n mod 10 So, the digits of a number n can be recovered as follows: 1. c 0 = (n mod 10) 2. c 1 = ((n c 0 )/10) mod 10 3. c 2 = ((n c 0 10c 1 )/100) mod 10

Number systems Everything applies to numbers written in other bases b > 1: n = i bi c i Binary numbers: b = 2. n = i 2i c i 1 10 11 100 101 110 111 Convert the number 134 to binary notation: (A) 10010110; (B) 10000110; (C) 11100110; (D) none

Other common bases Hexadecimal numbers: b = 16. Digits: 0,1,2,3,4,5,6,7,8,9,A= 10,B= 11,C= 12,D= 13,E= 14,F= 15 Octal: b = 8. Digits: 0,1,2,3,4,5,6,7 Convert between binary and hexadecimal. (Octal is similar.) Binary Hexadecimal Binary Hexadecimal 0000 0 1000 8 0001 1 1001 9 0010 2 1010 A 0011 3 1011 B 0100 4 1100 C 0101 5 1101 D 0110 6 1110 E 0111 7 1111 F

Addition with binary numbers Can you add 53 and 73? (A) 134; (B) 126; (C) Please, we are not in elementary school...

Addition with binary numbers Can you add 53 and 73? (A) 134; (B) 126; (C) Please, we are not in elementary school...... in binary? (53) 10 = (110101) 2 (73) 10 = (1001001) 2 110101 + 1001001 =???

Addition with binary numbers Can you add 53 and 73? (A) 134; (B) 126; (C) Please, we are not in elementary school...... in binary? (53) 10 = (110101) 2 (73) 10 = (1001001) 2 110101 + 1001001 =??? (11111110) 2 = (???) 10 (A) 135; (B) 126; (C) 118; (D) 134

Multiplication with binary numbers Can you multiply - (53) 10 = (110101) 2 - (73) 10 = (1001001) 2

Multiplication with binary numbers Can you multiply - (53) 10 = (110101) 2 - (73) 10 = (1001001) 2 110101 1001001 =??? 1001001 = 1000000 + 1000 + 1 110101 1000000 = 110101000000 110101 1000 = 110101000 110101 1 = 110101

Multiplication with binary numbers Can you multiply - (53) 10 = (110101) 2 - (73) 10 = (1001001) 2 110101 1001001 =??? 1001001 = 1000000 + 1000 + 1 110101 1000000 = 110101000000 110101 1000 = 110101000 110101 1 = 110101 110101 1001001 = 110101 (1000000 + 1000 + 1) = 110101000000 + 110101000 + 110101 =??? (A) 100101001001; (B) 111100011101; (C) 101100011101; (D) 111100011011