Foundations of Computing I CSE 311 Fall 2014. Review: Division Theorem Let a be an integer and d a positive integer. Then there are unique integers q.

Slides:



Advertisements
Similar presentations
1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
Advertisements

The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
Congruence class arithmetic. Definitions: a ≡ b mod m iff a mod m = b mod m. a  [b] iff a ≡ b mod m.
CSE115/ENGR160 Discrete Mathematics 03/15/11
Congruence of Integers
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
CS555Spring 2012/Topic 61 Cryptography CS 555 Topic 6: Number Theory Basics.
Integers Number Theory = Properties of Integers
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
CSE 504 Discrete Mathematics & Foundations of Computer Science
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
Discrete Mathematics CS 2610 March 17, Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or.
Prep Math Competition, Lec. 1Peter Burkhardt1 Number Theory Lecture 1 Divisibility and Modular Arithmetic (Congruences)
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Copyright © Curt Hill Divisibility and Modular Arithmetic A Topic in Number Theory.
Chapter 3 Elementary Number Theory and Methods of Proof.
Chapter The Integers and Division Division
Foundations of Computing I CSE 311 Fall It’s Boolean algebra again Definition for  based on  Definition for  based on  Complement works like.
Number Theory 이재원 School of Information Technology Sungshin W. University.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Direct Proof and Counterexample III
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Discrete Mathematics
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
Divisibility and Modular Arithmetic
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 11 Modular Exponentiation and Primes Autumn 2011 CSE 3111.
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
The Relation Induced by a Partition
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
CSE15 Discrete Mathematics 03/15/17
Congruence class arithmetic
Advanced Algorithms Analysis and Design
Integers and Division Section 3.4.
CMSC Discrete Structures
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Number Theory.
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
Modular Arithmetic and Change of Base
CSE 311 Foundations of Computing I
Direct Proof and Counterexample III
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Applied Discrete Mathematics Week 10: Introduction to Counting
Clements MAΘ October 30th, 2014
Number Theory.
Presentation transcript:

Foundations of Computing I CSE 311 Fall 2014

Review: Division Theorem Let a be an integer and d a positive integer. Then there are unique integers q and r, with 0 ≤ r < d, such that a = dq + r. q = a div d r = a mod d

Review: Modular Arithmetic Let a and b be integers, and m be a positive integer. We say a is congruent to b modulo m if m divides a – b. We use the notation a ≡ b (mod m) to indicate that a is congruent to b modulo m.

Review: Divisibility Integers a, b, with a ≠ 0, we say that a divides b if there is an integer k such that b = ka. The notation a | b denotes “a divides b.”

CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications

Modular Arithmetic: A Property Let a and b be integers, and let m be a positive integer. Then a ≡ b (mod m) if and only if a mod m = b mod m.

Modular Arithmetic: A Property Let a and b be integers, and let m be a positive integer. Then a ≡ b (mod m) if and only if a mod m = b mod m. Proof: Suppose that a ≡ b (mod m). By definition: a ≡ b (mod m) implies m | (a – b) which by definition implies that a – b = km for some integer k. Therefore a=b+km. Taking both sides modulo m we get a mod m=(b+km) mod m = b mod m. Suppose that a mod m = b mod m. By the division theorem, a = mq + (a mod m) and b = ms + (b mod m) for some integers q, s. a – b = (mq + (a mod m)) – (ms + (b mod m)) = m(q – s) + (a mod m – b mod m) = m(q – s) since a mod m = b mod m Therefore m |(a-b) and so a ≡ b (mod m).

Modular Arithmetic: Another Property Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then a + c ≡ b + d (mod m)

Modular Arithmetic: Another Property Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then a + c ≡ b + d (mod m) Suppose a ≡ b (mod m) and c ≡ d (mod m). Unrolling definitions gives us some integer k such that a – b = km, and some integer j such that c – d = jm. Adding the equations together gives us (a + c) – (b + d) = m(k + j). Now, re-applying the definition of mod gives us a + c ≡ b + d (mod m).

Modular Arithmetic: Another-nother Property Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then ac ≡ bd (mod m)

Modular Arithmetic: Another-nother Property Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then ac ≡ bd (mod m) S uppose a ≡ b (mod m) and c ≡ d (mod m). Unrolling definitions gives us some integer k such that a – b = km, and some integer j such that c – d = jm. Then, a = km + b and c = jm + d. Multiplying both together gives us ac = (km + b)(jm + d) = kjm 2 + kmd + jmb + bd. Re-arranging gives us ac – bd = m(kjm + kd + jb). Using the definition of mod gives us ac ≡ bd (mod m).

Example Let n be an integer. Prove that n 2 ≡ 0 (mod 4) or n 2 ≡ 1 (mod 4)

Example Let n be an integer. Prove that n 2 ≡ 0 (mod 4) or n 2 ≡ 1 (mod 4) Let’s start by looking at a small example: 0 2 = 0 ≡ 0 (mod 4) 1 2 = 1 ≡ 1 (mod 4) 2 2 = 4 ≡ 0 (mod 4) 3 2 = 9 ≡ 1 (mod 4) 4 2 = 16 ≡ 0 (mod 4) It looks like n ≡ 0 (mod 2) → n 2 ≡ 0 (mod 4), and n ≡ 1 (mod 2) → n 2 ≡ 1 (mod 4).

Example Let n be an integer. Prove that n 2 ≡ 0 (mod 4) or n 2 ≡ 1 (mod 4) Let’s start by looking at a small example: 0 2 = 0 ≡ 0 (mod 4) 1 2 = 1 ≡ 1 (mod 4) 2 2 = 4 ≡ 0 (mod 4) 3 2 = 9 ≡ 1 (mod 4) 4 2 = 16 ≡ 0 (mod 4) It looks like n ≡ 0 (mod 2) → n 2 ≡ 0 (mod 4), and n ≡ 1 (mod 2) → n 2 ≡ 1 (mod 4). Case 1 (n is even): Suppose n ≡ 0 (mod 2). Then, n = 2k for some integer k. So, n 2 = (2k) 2 = 4k 2. So, by definition of congruence, n 2 ≡ 0 (mod 4). Case 2 (n is odd): Suppose n ≡ 1 (mod 2). Then, n = 2k + 1 for some integer k. So, n 2 = (2k + 1) 2 = 4k 2 + 4k + 1 = 4(k 2 + k) + 1. So, by definition of congruence, n 2 ≡ 1 (mod 4).

n-bit Unsigned Integer Representation

Sign-Magnitude Integer Representation

Two’s Complement Representation Key property: Twos complement representation of any number y is equivalent to y mod 2 n so arithmetic works mod 2 n

Sign-Magnitude vs. Two’s Complement Sign-Magnitude Two’s complement

Two’s Complement Representation

Basic Applications of mod Hashing Pseudo random number generation Simple cipher

Hashing

Pseudo-Random Number Generation Linear Congruential method

Simple Ciphers Caesar cipher, A = 1, B = 2,... – HELLO WORLD Shift cipher – f(p) = (p + k) mod 26 – f -1 (p) = (p – k) mod 26 More general – f(p) = (ap + b) mod 26

modular exponentiation mod 7 X aa1a1 a2a2 a3a3 a4a4 a5a5 a6a

X aa1a1 a2a2 a3a3 a4a4 a5a5 a6a

X aa1a1 a2a2 a3a3 a4a4 a5a5 a6a