• Tidak ada hasil yang ditemukan

ICS-252 Discrete Structure II

N/A
N/A
Protected

Academic year: 2019

Membagikan "ICS-252 Discrete Structure II"

Copied!
12
0
0

Teks penuh

(1)

ICS-252 Discrete Structure II

Lecture 2

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

Outlines

Modular Arithmetic (DMA-203-205)

Theorem 3, 4, 5

Example 5, 6

Applications of Congruences

(DMA-205-208)

DMA=Discrete Mathematics and its

Applications

(2)

Modular Arithmetic

•In mathematics, modular arithmetic(sometimes called 

clock arithmetic) is a system of  arithmetic for integers, where 

numbers "wrap around" after they reach a certain value—the 

modulus m Modular arithmetic was introduced by Carl 

modulus m. Modular arithmetic was introduced by Carl 

Friedrich Gauss in his book Disquisitiones Arithmeticae, 

published in 1801.

Time‐keeping on a clock gives an example of modular 

arithmetic.

A familiar use of modular arithmetic is its use in the 12‐hour 

A familiar use of modular arithmetic is its use in the 12 hour 

clock, in which the day is divided into two 12 hour periods. If the 

time is 7:00 now, then 8 hours later it will be 3:00. Usual addition 

would suggest that the later time should be 7 + 8 = 15, but this is 

not the answer because clock time "wraps around" every 12 

hours; there is no "15 o'clock". 

3 ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

Modular Arithmetic

• Likewise, if the clock starts at 12:00 (noon) and 21 hours 

elapse, then the time will be 9:00 the next day, rather than 

33:00. Since the hour number starts over when it reaches 12, 

this is arithmetic modulo12 (m=12).

4 ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

(3)

Modular Arithmetic

Modular arithmetic can be handled mathematically by

introducing a

congruence relation

on the integers that

is compatible with the operations of the ring of integers

is compatible with the operations of the ring of integers

a

ring

is an algebraic structure consisting of a set

together with two binary operations

(usually called

addition and multiplication).

For a positive integer

m

, two integers

a

and

b

are said to

be

congruent modulo

m

, Therefore we can write a

mod

m = b

mod

m

5 ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

Modular Arithmetic

Theorem 3: Let a and b be integers, and let m be a positive

integer, Then a ≡ b (mod m) if and only if a modm = b mod

m.

Proof: If suppose a mod m = b mod m, then a and b have the

same remainder when divided by m.

Hence, a = q1m + r and b = q2m + r, where 0 ≤ r < m. It follows that a – b = (q1- q2

)

m , So m | (a – b) . It follows that a ≡ b (mod m) .

6

Note: m | (a - b) we can read as- m evaluates for a –b

(4)

Modular Arithmetic

Example 5:Determine whether 17 is congruent to 5 modulo 6 and whether 24 and 14 are congruent modulo 6

Solution:Because 6 divides 17 – 5 = 12, We see that 17 ≡ 5 (mod 6)

However, because 24 – 14 = 10 is not divisible by 6, We see that 24 is not congruent with 14 (mod 6).

(5)

Applications of Congruences

• Hashing Functions

• Pseudorandom Numbers • Cryptology

Hashing Functions: Hashing Functions:

Question:The central computer at Riyad Bank maintains records (Bank account) for each of its customers. How can memory locations be assigned so that customer records can be retrieved quickly?

Solution: The solution to this problem is to use a suitably

9 chosen Hashing Function. Customer records are indentified using a Key, which will be called Hash Key, which uniquely identify each customer’s Bank account record. In this case

Bank account numberwill be the key.

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

Applications of Congruences

In general term a hashing function h assigns memory location h(k) to a record that has k as its key. There are many hashing functions. One of the most common is the function h(k) = k mod m where m is the number of function- h(k) = k mod m, where m is the number of available memory locations.

To find h(k) we only compute the remainder when k is divided by m.

Example:suppose m=111, the record of the customer

with Bank Account number 064212848 is

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail.  10 h(064212848) = 064212848 mod 111 = 14

h(037149212) = 037149212 mod 111 = ?

(6)

Applications of Congruences

Pseudorandom Numbers:Randomly chosen numbers are

often needed for computer simulations. Its also useful in cryptography. The numbers generated by systematic methods are not truly random they are called

methods are not truly random, they are called pseudorandom numbers.

Linear Congruential Method:It is a most commonly used

method to generate Pseudorandom Numbers. Let us Consider four integers: the modulus m, multiplier a, increment cand seed x0with 2 ≤ a < m, 0 ≤ c < m,

d 0≤ < Th W t f

and 0 ≤ x0 < m. Then We can generate a sequence of pseudorandom numbers {xn}, with 0 ≤ xn< m for all n, by successfully using the congruence

x

n+1

= ( ax

n

+ c) mod m.

11 ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

Applications of Congruences

Example:Consider m = 9, a = 7, c = 4, and x0= 3, then we

can generate the sequence of pseudorandom numbers as by using xn+1= ( axn+ c) mod m.

Solution:

x1= ( 7x0+ 4 ) mod 9 = ( 7. 3 + 4 ) mod 9 = 25 mod 9 = 7

x2= ( 7x1+ 4 ) mod 9 = ( 7. 7 + 4 ) mod 9 = 53 mod 9 = 8

x3= ( 7x2+ 4 ) mod 9 = ( 7. 8 + 4 ) mod 9 = 60 mod 9 = 6

x4= ( 7x3+ 4 ) mod 9 = ( 7. 6 + 4 ) mod 9 = 46 mod 9 = 1

x5= ( 7x4+ 4 ) mod 9 = ( 7. 1 + 4 ) mod 9 = 11 mod 9 = 2

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail.  12

x6= ( 7x5+ 4 ) mod 9 = ( 7. 2 + 4 ) mod 9 = 18 mod 9 = 0

x7= ( 7x6+ 4 ) mod 9 = ( 7. 0 + 4 ) mod 9 = 4 mod 9 = 4

x8= ( 7x7+ 4 ) mod 9 = ( 7. 4 + 4 ) mod 9 = 32 mod 9 = 5

(7)

Applications of Congruences

In this example, x9 = x0 and because each term depend on the previous term. This sequence contains nine different numbers before repeating.

Most computers do use linear congruential

Most computers do use linear congruential

generators to generate pseudorandom numbers.

A Linear congruential generator with increment c = 0 is used, such a generator is called a pure

multiplicative generator. For example, the pure

multiplicative generator with modulus

d l i li i id l

2

d Wi h

1

numbers are generated before repetition begins.

807

y Cryptology:Congruences have many applications in 

(8)

Applications of Congruences

y Encryption Scheme:

A

B

C

D

E

F

G

H

I

J

A

B

C

D

E

F

G

H

I

J

0

1

2

3

4

5

6

7

8

9

K

L

M N

O

P

Q

R

S

T

10 11 12 13 14 15 16 17 18 19

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

15

U

V

W X

Y

Z

20 21 22 23 24 25

Applications of Congruences

y Therefore Caesar encryption method can be represented

mathematically as mathematically as

y f(p) = ( p + 3) mod 26

y Function f that assigns to the nonnegative integers p, p ≤ 25, the

Integer f(p) in the set of {0,1,2,3,4,……25 }.

y In the encrypted version of message, the letter represented by pIn the encrypted version of message, the letter represented by p

is replaced with the letter represented by (p + 3) mod 26

(9)

Applications of Congruences

y Example 9: What is the secret message produced from the

message “MEET YOU IN THE PARK” using f(p) = ( p + 3) mod 26 method of encryption.

y Solution:First replace the letters in the message with

numbers. This produces

y Translating this back to letters produces the encrypted message-“PHHW BRX LQ WKH SDUN “

encrypted message is called decryption.

(10)

Applications of Congruences

y It is obvious, that Caesar’s method does not provide a high

l l f it Th i t h thi

level of security. There are various ways to enhance this

method. One approach that slightly enhances the security

is to use a function of the form;

y f(p) = ( ap + b ) mod 26

y Where a and b are integers chosen such that f is a y Where a and b are integers, chosen such that f is a

bijection (one-to-one mapping). Such mapping is called

Affine Transformation.

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

19

Applications of Congruences

y Example 10:What letter replaces the letter k when the

function f(p) ( 7p + 3) mod 26 is used for encryption? function f(p) = ( 7p + 3) mod 26 is used for encryption?

y Solution:First note that 10 represent K. Then, using

y f(p) = ( 7p + 3) mod 26

y f(10) = ( 7.10 + 3) mod 26 = 73 mod 26 = 21

y Because 21 represents V, therefore K is replaced by V

in the encrypted message.

ICS‐252:  Dr. Salah Omer, Assistant Professor, CSSE, University  of  Hail. 

(11)

Home

 

Work

y Question 4: What sequence of pseuorandom numbers generated  using the linear congruential generator   xn+1= ( 4 xn+1 ) mod 7 with 

translating the letters into numbers, applying the encryption functions  given, and then translating the numbers back into letters.

y Question 7: Decrypt these messages   using

(12)

Thank you for your Attention.

23

Referensi

Dokumen terkait

Pengembangan Wacana dan Praktik Pembelajaran dalam Pembangunan Nasional. Jogjakarta:

by : T. Percobaan dilakukan di daerah yang padat penduduknya seluas satu kilometer persegi di Jakarta. The WHO Research Unit at Dar-es-Salaam found that OMS-971 or

1) Mahasiswa yang memperoleh nilai 1 (satu) dengan IPK &gt; 2,00 tidak wajib mengikuti mata kuliah yang bersangkutan dan yang memperoleh nilai 0 wajib mengikuti

Skripsi ini disusun untuk memenuhi salah satu syarat dalam menempuh ujian akhir Program Studi S1 Keperawatan Fakultas Ilmu Kesehatan di Universitas Muhammadiyah

Anggaran yang bersumber dari APBD I yang dialokasikan untuk Bidang Cipta Karya. di Kabupaten Bungo sangat minim sekali, yang selalu ada hanya untuk

hidayah dan kasih sayang – Nya, sehingga penulis dapat menyusun dan menyelesaikan skripsi ini dengan judul “Peningkatan kemampuan motorik halus anak melalui

penulisan Studi Kasus dengan judul “Asuhan Kep erawatan Gerontik pada Klien dengan Diagnosa Medis Gout Artritis dengan Masalah Keperawatan Nyeri Kronis di UPTD

Kedudukan, Susunan Organisasi, Tugas, Fungsi dan Uraian Serta Tata Kerja Perangkat daerah Bidang Cipta Karya dalam Struktur Organisasi Pemerintah Kota Payakumbuh.. Badan Perencanaan