CSE 311: Foundations of Computing

Slides:



Advertisements
Similar presentations
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Advertisements

Number Theory and Cryptography
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
© 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.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
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.
Prep Math Competition, Lec. 1Peter Burkhardt1 Number Theory Lecture 1 Divisibility and Modular Arithmetic (Congruences)
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
MSU/CSE 260 Fall Functions Read Section 1.8.
Foundations of Computing I CSE 311 Fall It’s Boolean algebra again Definition for  based on  Definition for  based on  Complement works like.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311 Foundations of Computing I Lecture 10 Set Theory Autumn 2012 Autumn 2012CSE
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 8, 2004 Lecture Number: 7.
Foundations of Computing I CSE 311 Fall Review: Division Theorem Let a be an integer and d a positive integer. Then there are unique integers q.
Chapter 13 Mathematic Structures 13.1 Modular Arithmetic Definition 1 (modulo). Let a be an integer and m be a positive integer. We denoted by a mod m.
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
Divisibility and Modular Arithmetic
August 2003 CIS102/LECTURE 9/FKS 1 Mathematics for Computing Lecture 9 LOGIC Chapter 3.
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.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
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,
Topic: Binary Encoding – Part 2
Addition and Subtraction
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
CSE15 Discrete Mathematics 03/15/17
Introduction to Cryptography
Lecture 3.2: Public Key Cryptography II
Integers and Division Section 3.4.
CMSC Discrete Structures
CSE15 Discrete Mathematics 02/15/17
CSE 504 Discrete Mathematics & Foundations of Computer Science
Number Theory and Cryptography
CSE 311 Foundations of Computing I
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
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Lecture 20 Guest lecturer: Neal Gupta
CSE 311 Foundations of Computing I
Enough Mathematical Appetizers!
Modular Arithmetic and Change of Base
CSE 311 Foundations of Computing I
CSE 311: Foundations of Computing
EEL 3705 / 3705L Digital Logic Design
COMS 161 Introduction to Computing
CSE 321 Discrete Structures
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Section 10.3 Modular Arithmetic
Copyright © Zeph Grunschlag,
Applied Discrete Mathematics Week 10: Introduction to Counting
Clements MAΘ October 30th, 2014
Number Theory.
Number Theory.
Cryptography Lecture 16.
Lecture 3 Strings and Things (Section 1.1)
Section 9.3 Modular Arithmetic.
Presentation transcript:

CSE 311: Foundations of Computing Fall 2013 Lecture 10: Functions, Modular arithmetic

announcements Homework 3 due now Reading assignment Modular arithmetic 4.1-4.2, 7th edition 3.4-3.5, 6th edition Homework 3 due now Graded Homework 2 and Solutions available Homework 4 out later today

review: set theory 𝑥∈𝐴 : “x is an element of A” 𝑥∉𝐴 :  (𝑥∈𝐴) 𝑥∉𝐴 :  (𝑥∈𝐴) 𝐴⊆𝐵≡∀𝑥 (𝑥∈𝐴→𝑥∈𝐵) 𝐴=𝐵 ↔ 𝐴⊆𝐵∧𝐵⊆𝐴 𝐴∪𝐵={ 𝑥 : 𝑥∈𝐴 ∨ 𝑥 ∈𝐵 } 𝐴∩𝐵={ 𝑥 : 𝑥∈𝐴 ∧ 𝑥∈𝐵 } 𝒫(𝐴)={ 𝐵:𝐵⊆𝐴} 𝐴×𝐵={(𝑎,𝑏):𝑎∈𝐴,𝑏∈𝐵} Some applications: Characteristic vectors, private key cryptography

functions review A function from 𝑨 to 𝑩 an assignment of exactly one element of 𝑩 to each element of 𝑨. We write 𝒇 :𝑨→𝑩. “Image of 𝒂” = 𝒇(𝒂) Domain of 𝒇: 𝑨 Codomain of 𝒇: 𝑩 Range of 𝒇 = set of all images of elements of 𝑨

image, preimage 𝐴 𝐵 1 a b 2 c 3 d 4 e

is this a function? one-to-one? onto? 1 a b 2 c 3 d 4 e 5 6

number theory (and applications to computing) Branch of Mathematics with direct relevance to computing Many significant applications Cryptography Hashing Security Important tool set

modular arithmetic Arithmetic over a finite domain In computing, almost all computations are over a finite domain

what are the values computed? public void Test1() { byte x = 250; byte y = 20; byte z = (byte) (x + y); Console.WriteLine(z); } public void Test2() { sbyte x = 120; sbyte y = 20; sbyte z = (sbyte) (x + y); Console.WriteLine(z); } [-128, 127] 14 -116

what are the values computed?

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.”

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 Note: r ≥ 0 even if a < 0. Not quite the same as a%d

a +7 b = (a + b) mod 7 a 7 b = (a  b) mod 7 arithmetic mod 7 a +7 b = (a + b) mod 7 a 7 b = (a  b) mod 7 + 1 2 3 4 5 6 X 1 2 3 4 5 6

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.

modular arithmetic 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 Let m be a positive integer. If a ≡ b (mod m) and c ≡ d (mod m), then a + c ≡ b + d (mod m) and ac ≡ bd (mod m)

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

n-bit unsigned integer representation Represent integer x as sum of powers of 2: If 𝑥= 𝑖=0 𝑛−1 𝑏 𝑖 2 𝑖 where each bi ∈ {0,1} then representation is bn-1...b2 b1 b0 99 = 64 + 32 + 2 + 1 18 = 16 + 2 For n = 8: 99: 0110 0011 18: 0001 0010

signed integer representation n-bit signed integers Suppose − 2 𝑛−1 <𝑥< 2 𝑛−1 First bit as the sign, n-1 bits for the value 99 = 64 + 32 + 2 + 1 18 = 16 + 2 For n = 8: 99: 0110 0011 -18: 1001 0010 Any problems with this representation?

two’s complement representation n bit signed integers, first bit will still be the sign bit Suppose 0≤𝑥< 2 𝑛−1 , 𝑥 is represented by the binary representation of 𝑥 Suppose 0≤𝑥≤ 2 𝑛−1 , −𝑥 is represented by the binary representation of 2 𝑛 −𝑥 99 = 64 + 32 + 2 + 1 18 = 16 + 2 For n = 8: 99: 0110 0011 -18: 1110 1110 Key property: Twos complement representation of any number y is equivalent to y mod 2n so arithmetic works mod 2n

signed vs two’s complement -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 1111 1110 1101 1100 1011 1010 1001 0000 0001 0010 0011 0100 0101 0110 0111 Signed -8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0010 0011 0100 0101 0110 0111 Two’s complement

two’s complement representation For 0<𝑥≤ 2 𝑛−1 , −𝑥 is represented by the binary representation of 2 𝑛 −𝑥 To compute this: Flip the bits of 𝑥 then add 1: All 1’s string is 2 𝑛 −1, so Flip the bits of 𝑥  replace 𝑥 by 2 𝑛 −1−𝑥