a mec hanical pro of of the chinese remainder theorem da
play

A Mec hanical Pro of of the Chinese Remainder Theorem Da - PDF document

A Mec hanical Pro of of the Chinese Remainder Theorem Da vid M. Russino Adv anced Micro Devices, Inc. david.russinoff@a md. co m http://www.onr.c om /us er /ru ss /da vid Informal Statemen t L et m ; : : :


  1. A Mec hanical Pro of of the Chinese Remainder Theorem Da vid M. Russino� Adv anced Micro Devices, Inc. david.russinoff@a md. co m http://www.onr.c om /us er /ru ss /da vid

  2. Informal Statemen t L et m ; : : : ; m b e p airwise r elatively Theorem N 2 1 k prime mo duli and let a ; : : : ; a . Ther e exists x N N 2 2 1 k such that x a (mo d m ) � 1 1 x a (mo d m ) � 2 2 . . . x a (mo d m ) : � k k If x 0 satis�es the same c ongruenc es, then 0 x x (mo d m m m ) : � � � � k 1 2 1

  3. A CL2 F ormalization (defun g-c-d (x y) (declare (xargs :measure (nfix (+ x y)))) (if (zp x) y (if (zp y) x (if (<= x y) (g-c-d x (- y x)) (g-c-d (- x y) y))))) (defun rel-prime (x y) (= (g-c-d x y) 1)) (defun congruent (x y m) (= (rem x m) (rem y m))) (defun congruent-all (x a m) (if (endp m) t (and (congruent x (car a) (car m)) (congruent-al l x (cdr a) (cdr m))))) (defthm chinese-remain de r-t he or em (implies (and (natp-all a) (rel-prime-modu li m) (= (len a) (len m))) (and (natp (crt-witness a m)) (congruent-all (crt-witness a m) a m)))) 2

  4. Informal Pro of If x; y ar e r elatively prime, then ther e Lemma 1 N 2 exists s such that sy 1 (mo d x ). Z 2 � If x; y ; z and x is r elatively prime to b oth Lemma 2 N 2 y and z , then x is r elatively prime to y z . Pro of of CR T: Let M = m m m . F or i = 1 ; : : : ; k , let � � � 1 2 k M = M =m and �nd s suc h that s M 1 (mo d m ). Let � i i i i i i x = a s M + a s M + + a s M : � � � k k k 1 1 1 2 2 2 Then x a s M a (mo d m ) : � � i i i i i 3

  5. Example Supp ose w e ha v e 10000 50000 and N � � 6 (mo d 25) N � 13 (mo d 36) N � 28 (mo d 49) N � Then w e ma y solv e for as follo ws: N = 25 36 49 = 44100 M � � = 36 49 = 1764 M � 1 = 25 49 = 1225 M � 2 = 25 36 = 900 M � 3 1764 s 1 (mo d 25) 14 s 1 (mo d 25) 9 (mo d 25) s � , � , � 1 1 1 1225 s 1 (mo d 36) 1 (mo d 36) s � , � 2 2 900 s 1 (mo d 49) 18 s 1 (mo d 49) 30 (mo d 49) s � , � , � 3 3 3 = 6, = 13, = 28 a a a 1 2 3 = + + x a M s a M s a M s 1 1 1 2 2 2 3 3 3 = 6 1764 9 + 13 1225 1 + 28 900 30 � � � � � � = 867281 29281 (mo d 44100) � = 29281 N 5

  6. Pro of of Lemma 1 If x; y ar e r elatively prime, then ther e Lemma 1 N 2 exists s such that sy 1 (mo d x ). Z 2 � This is a sp ecial case of the follo wing: F or al l x; y , ther e exist r ; s such that 2 N 2 Z r x sy g cd ( x; y ) . + = The pro of is b y induction on x + y : (1) If x = 0, then r = 0 and s = 1. (2) If y = 0, then r = 1 and s = 0. (3) If 0 < x y , then �nd r 0 and s 0 suc h that � 0 0 r x + s ( y x ) = g cd ( x; y x ) = g cd ( x; y ) � � and let r = r 0 s 0 and s = s 0 . Then � 0 0 0 0 0 r x + sy = ( r s ) x + s y = r x + s ( y x ) = g cd ( x; y ) : � � < y < x , r s (4) If 0 then �nd 0 and 0 suc h that r 0 ( x y ) + s 0 y = g cd ( x y ; y ) = g cd ( x; y ) � � and let r = r 0 and s = s 0 r 0 . � 6

  7. F ormal Pro of (mutual-recurs io n (defun r (x y) (declare (xargs :measure (nfix (+ x y)))) (if (zp x) 0 (if (zp y) 1 (if (<= x y) (- (r x (- y x)) (s x (- y x))) (r (- x y) y))))) (defun s (x y) (declare (xargs :measure (nfix (+ x y)))) (if (zp x) 1 (if (zp y) 0 (if (<= x y) (s x (- y x)) (- (s (- x y) y) (r (- x y) y)))))) ) (defthm r-s-lemma (implies (and (natp x) (natp y)) (= (+ (* (r x y) x) (* (s x y) y)) (g-c-d x y)))) 7

  8. Pro of of Lemma 2 If x; y ; z and x is r elatively prime to b oth Lemma 2 N 2 y and z , then x is r elatively prime to y z . This is a consequence of the follo wing basic prop erties of g cd and primes: (1) g cd ( x; y ) divides b oth x and y . (2) If d divides b oth x and y , then d divides g cd ( x; y ) . (3) If x > 1 , then some prime divides x . (4) If a prime p divides ab , then p divides either a or b . It w ould tak e some w ork to pro v e these in A CL2. F ortunately , there is a more direct route to CR T. 8

  9. Alternate Approac h L et x; y ; y ; : : : ; y and p = y y . If Lemma 3 N 2 � � � 1 2 k 1 k x is r elatively prime to e ach y , then ther e exist c; d Z 2 i such that cx + dp = 1 . Pro of: Let p 0 = y y . Assume that � � � 1 k � 1 r x + sy = 1 k and, b y induction, that 0 0 0 c x + d p = 1 : Then 0 0 0 ( sd ) p = ( sy )( d p ) k 0 = (1 r x )(1 c x ) � � 0 0 = 1 ( r + c r c x ) x: � � Th us, if c = r + c 0 r c 0 x and d = sd 0 , then � cx + dp = 1 : 9

  10. F ormal Pro of (defun c (x l) (if (endp l) 0 (- (+ (r x (car l)) (c x (cdr l))) (* (r x (car l)) (c x (cdr l)) x)))) (defun d (x l) (if (endp l) 1 (* (s x (car l)) (d x (cdr l))))) (defthm c-d-lemma (implies (and (natp x) (natp-all l) (rel-prime-all x l)) (= (+ (* (c x l) x) (* (d x l) (prod l))) 1))) 10

  11. De�nition of crt-witness (defun one-mod (x l) (* (d x l) (prod l) (d x l) (prod l))) (defthm rem-one-mod-1 (implies (and (natp x) (> x 1) (natp-all l) (rel-prime-all x l)) (= (rem (one-mod x l) x) 1))) (defthm rem-one-mod-0 (implies (and (natp x) (> x 1) (rel-prime-modu li l) (rel-prime-all x l) (member y l)) (= (rem (one-mod x l) y) 0))) (defun crt1 (a m l) (if (endp a) 0 (+ (* (car a) (one-mod (car m) (remove (car m) l))) (crt1 (cdr a) (cdr m) l)))) (defun crt-witness (a m) (crt1 a m m)) 11

  12. The Main Lemma W e pro v e the follo wing generalization of CR T: (defthm crt1-lemma (implies (and (natp-all a) (rel-prime-modu li l) (sublistp m l) (= (len a) (len m))) (congruent-all (crt1 a m l) a m))) The pro of is b y induction, as suggested b y the de�nition: (defun crt1 (a m l) (if (endp a) 0 (+ (* (car a) (one-mod (car m) (remove (car m) l))) (crt1 (cdr a) (cdr m) l)))) In the inductiv e case, the conclusion of the lemma expands as follo ws: (and (congruent (+ (* (car a) (one-mod (car m) (remove (car m) l))) (crt1 (cdr a) (cdr m) l)) (car a) (car m)) (congruent-al l (+ (* (car a) (one-mod (car m) (remove (car m) l))) (crt1 (cdr a) (cdr m) l)) (cdr a) (cdr m))). 12

  13. The Final Result CR T is deriv ed as an instance of crt1-lemma : (defthm crt1-lemma (implies (and (natp-all a) (rel-prime-modu li l) (sublistp m l) (= (len a) (len m))) (congruent-all (crt1 a m l) a m))) (defthm chinese-remain de r-t he or em (implies (and (natp-all a) (rel-prime-modu li m) (= (len a) (len m))) (and (natp (crt-witness a m)) (congruent-all (crt a m) a m)))) 13

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend