Download Examples of Congruence

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CMPS 2433 – Coding Theory
Chapter 3
2
Cryptography - Coding
The Code Book, Simon Singh
Public-key cryptography
Number theory
Codes & Error-Correcting Codes
Error Checking - Accuracy
Even/Odd Parity
Each byte transmitted has one bit added so
number of ones is even (or odd)
Checked upon receipt – reject if number of
ones is NOT even (odd)
>99% of all transmission errors are in one bit
Example
Original: 0110 0011 Sent: 0110 0011 0
0111 0101  0111 0101 1
Error Correcting Parity
Send a set of multiple (8) bytes as a matrix.
Set parity bit on rows & columns
Example
1111
0000
0010
0110
1111
0000
0010
1110
Error Correcting Parity
Send a set of multiple (8) bytes as a matrix.
Set parity bit on rows & columns
Example – even parity
1111
0000
0010
0110
1011
1111
0000
0010
1110
0011
0
0
0
1
Error Correcting Parity
Send a set of multiple (8) bytes as a matrix.
Set parity bit on rows & columns
Example – even parity – one bit error
1111 1111 0
0000 0100 0*
0010 0010 0
0110 1110 1
1011 0011
*
Division Algorithm
If m & n are integers, m ≠ 0, n can be written as
n = m*q + r, where 0 <= r < |m|.
q & r are the quotient & remainder of n/m
Examples:
Divide 82 by 7 ~~ 82 = 11 * 7 + 5
Divide 26 by 7 ~~ 26 = 3 * 7 + 5
* 82 & 26 are Congruent Modulo 7 because they
have the same remainder
Congruence ~ is a Relation
Define the congruence relation as follows:
Cm = {(a,b)| a & b are integers & have the same
remainder when divided by m}
Example:
C7 = {(82,26), (5,12), (19,5) (4,11), (2,23) (49,0)…}
Properties of Congruence
Reflexive?
Symmetric?
Transitive?
Notation: 82 ≡ 26 mod 7
49 ≡ 0 mod 7
 Are there equivalence classes?
Equivalence Classes for Congruence
Given Cm, how many equivalence classes?
Example: Consider C7
[0] = {
[1] = {
[2] = {
Any more???
Equivalence Classes for Congruence
Given Cm, how many equivalence classes?
Example: C7
[0] = {0, 7, 14, 21,…}
[4] =
[1] = {1, 8, 15, 22,…}
[5] =
[2] = {2, 9, 16, 23,…}
[6] =
[3] = {3, 10, 17, 24…}
[7] =
Examples of Congruence
Clock Time Hours:
(mod 12) + 1
mod 24
Clock Time Minutes
mod 60
Examples of Congruence
Calendars ~ Days of the Week
If Sunday = 0, Monday = 1, etc…..
Mod 7 will give us days of week IF used
correctly
Note on Modulus on Negatives
If m & n are integers, m ≠ 0, n can be written as n
= m*q + r, where 0 <= r < |m|. (Note r MUST be positive)
q & r are the quotient & remainder of n/m
Examples: -34/7 – Which is correct??
-34 = -4 * 7 – 6
r = -6
-34 = -5 * 7 + 1
r=1
Euclidean Algorithm
*Greatest Common Divisor (GCD)
Given 2 integers A & B, the largest integer that
divides both is called the Greatest Common
divisor (GCD)
Examples:
GCD (12,8)
GCD (200, 1000)
GCD (7, 122)
Theorem 3.3 (p.107)
Let a, b, c, & q be integers with b > 0.
If a = qb + c, then gcd(a,b) = gcd(b,c)
Example: find gcd(105, 231)
gcd(231, 105)
231 = 2 * 105 + 21
gcd(105, 21)
105 = 5 * 21 + 0
gcd(21, 0) = 21
The Euclidean Algorithm (p.108)
Calculates gcd(m,n)
r-1 = m, r0 = n, I = 0
While rI≠0 //(division algorithm)
I = I + 1
determine qI, rI for rI-2/rI-1
Print rI-1
Complexity of Euclidean Algorithm
Lame – 1844: no more than 5 * number of
digits in smaller of 2 numbers
Theorem 3.4 (p. 109)
If the Euclidean Alg. is applied to m & n with
m ≥ n > 0, the number of divisions needed is
less than or equal to 2 log2 (n+1).
Thus, O(log2 n).
Related documents