MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  divalgmod Structured version   Unicode version

Theorem divalgmod 13732
Description: The result of the  mod operator satisfies the requirements for the remainder  r in the division algorithm for a positive divisor (compare divalg2 13731 and divalgb 13730). This demonstration theorem justifies the use of  mod to yield an explicit remainder from this point forward. (Contributed by Paul Chapman, 31-Mar-2011.)
Assertion
Ref Expression
divalgmod  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  =  ( N  mod  D )  <-> 
( r  e.  NN0  /\  ( r  <  D  /\  D  ||  ( N  -  r ) ) ) ) )
Distinct variable groups:    D, r    N, r

Proof of Theorem divalgmod
Dummy variable  z is distinct from all other variables.
StepHypRef Expression
1 zre 10765 . . . . . . . 8  |-  ( N  e.  ZZ  ->  N  e.  RR )
2 nnrp 11115 . . . . . . . 8  |-  ( D  e.  NN  ->  D  e.  RR+ )
3 modlt 11839 . . . . . . . 8  |-  ( ( N  e.  RR  /\  D  e.  RR+ )  -> 
( N  mod  D
)  <  D )
41, 2, 3syl2an 477 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  <  D )
5 nnre 10444 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  RR )
6 nnne0 10469 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  =/=  0 )
7 redivcl 10165 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR  /\  D  =/=  0 )  ->  ( N  /  D )  e.  RR )
81, 5, 6, 7syl3an 1261 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN  /\  D  e.  NN )  ->  ( N  /  D )  e.  RR )
983anidm23 1278 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  /  D
)  e.  RR )
109flcld 11769 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  ZZ )
11 nnz 10783 . . . . . . . . 9  |-  ( D  e.  NN  ->  D  e.  ZZ )
1211adantl 466 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  ZZ )
13 zmodcl 11848 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  NN0 )
1413nn0zd 10860 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  ZZ )
15 zsubcl 10802 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  ( N  mod  D )  e.  ZZ )  -> 
( N  -  ( N  mod  D ) )  e.  ZZ )
1614, 15syldan 470 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  -  ( N  mod  D ) )  e.  ZZ )
17 nncn 10445 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  CC )
1817adantl 466 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  CC )
1910zcnd 10863 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  CC )
2018, 19mulcomd 9522 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( ( |_
`  ( N  /  D ) )  x.  D ) )
21 modval 11831 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR+ )  -> 
( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
221, 2, 21syl2an 477 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
23 zcn 10766 . . . . . . . . . . . . 13  |-  ( N  e.  ZZ  ->  N  e.  CC )
2423adantr 465 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  CC )
25 zmulcl 10808 . . . . . . . . . . . . . . 15  |-  ( ( D  e.  ZZ  /\  ( |_ `  ( N  /  D ) )  e.  ZZ )  -> 
( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2611, 10, 25syl2an 477 . . . . . . . . . . . . . 14  |-  ( ( D  e.  NN  /\  ( N  e.  ZZ  /\  D  e.  NN ) )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2726anabss7 817 . . . . . . . . . . . . 13  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2827zcnd 10863 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC )
2913nn0cnd 10753 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  CC )
30 subsub23 9730 . . . . . . . . . . . 12  |-  ( ( N  e.  CC  /\  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC  /\  ( N  mod  D )  e.  CC )  ->  (
( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) )  =  ( N  mod  D )  <->  ( N  -  ( N  mod  D ) )  =  ( D  x.  ( |_ `  ( N  /  D
) ) ) ) )
3124, 28, 29, 30syl3anc 1219 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) )  =  ( N  mod  D )  <->  ( N  -  ( N  mod  D ) )  =  ( D  x.  ( |_
`  ( N  /  D ) ) ) ) )
32 eqcom 2463 . . . . . . . . . . 11  |-  ( ( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) )  =  ( N  mod  D )  <->  ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
33 eqcom 2463 . . . . . . . . . . 11  |-  ( ( N  -  ( N  mod  D ) )  =  ( D  x.  ( |_ `  ( N  /  D ) ) )  <->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3431, 32, 333bitr3g 287 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) )  <->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) ) )
3522, 34mpbid 210 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3620, 35eqtr3d 2497 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )
37 dvds0lem 13665 . . . . . . . 8  |-  ( ( ( ( |_ `  ( N  /  D
) )  e.  ZZ  /\  D  e.  ZZ  /\  ( N  -  ( N  mod  D ) )  e.  ZZ )  /\  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
3810, 12, 16, 36, 37syl31anc 1222 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
39 divalg2 13731 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )
40 breq1 4406 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( z  <  D  <->  ( N  mod  D )  <  D ) )
41 oveq2 6211 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( N  -  z )  =  ( N  -  ( N  mod  D ) ) )
4241breq2d 4415 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( D  ||  ( N  -  z
)  <->  D  ||  ( N  -  ( N  mod  D ) ) ) )
4340, 42anbi12d 710 . . . . . . . . 9  |-  ( z  =  ( N  mod  D )  ->  ( (
z  <  D  /\  D  ||  ( N  -  z ) )  <->  ( ( N  mod  D )  < 
D  /\  D  ||  ( N  -  ( N  mod  D ) ) ) ) )
4443riota2 6187 . . . . . . . 8  |-  ( ( ( N  mod  D
)  e.  NN0  /\  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  ->  ( (
( N  mod  D
)  <  D  /\  D  ||  ( N  -  ( N  mod  D ) ) )  <->  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z
) ) )  =  ( N  mod  D
) ) )
4513, 39, 44syl2anc 661 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( ( N  mod  D )  < 
D  /\  D  ||  ( N  -  ( N  mod  D ) ) )  <-> 
( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) ) )
464, 38, 45mpbi2and 912 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) )
4746eqcomd 2462 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z
) ) ) )
4847sneqd 4000 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
49 snriota 6194 . . . . 5  |-  ( E! z  e.  NN0  (
z  <  D  /\  D  ||  ( N  -  z ) )  ->  { z  e.  NN0  |  ( z  <  D  /\  D  ||  ( N  -  z ) ) }  =  { (
iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
5039, 49syl 16 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { z  e.  NN0  |  ( z  <  D  /\  D  ||  ( N  -  z ) ) }  =  { (
iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
5148, 50eqtr4d 2498 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } )
5251eleq2d 2524 . 2  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  e.  {
( N  mod  D
) }  <->  r  e.  { z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
53 elsn 4002 . 2  |-  ( r  e.  { ( N  mod  D ) }  <-> 
r  =  ( N  mod  D ) )
54 breq1 4406 . . . 4  |-  ( z  =  r  ->  (
z  <  D  <->  r  <  D ) )
55 oveq2 6211 . . . . 5  |-  ( z  =  r  ->  ( N  -  z )  =  ( N  -  r ) )
5655breq2d 4415 . . . 4  |-  ( z  =  r  ->  ( D  ||  ( N  -  z )  <->  D  ||  ( N  -  r )
) )
5754, 56anbi12d 710 . . 3  |-  ( z  =  r  ->  (
( z  <  D  /\  D  ||  ( N  -  z ) )  <-> 
( r  <  D  /\  D  ||  ( N  -  r ) ) ) )
5857elrab 3224 . 2  |-  ( r  e.  { z  e. 
NN0  |  ( z  <  D  /\  D  ||  ( N  -  z
) ) }  <->  ( r  e.  NN0  /\  ( r  <  D  /\  D  ||  ( N  -  r
) ) ) )
5952, 53, 583bitr3g 287 1  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  =  ( N  mod  D )  <-> 
( r  e.  NN0  /\  ( r  <  D  /\  D  ||  ( N  -  r ) ) ) ) )
Colors of variables: wff setvar class
Syntax hints:    -> wi 4    <-> wb 184    /\ wa 369    = wceq 1370    e. wcel 1758    =/= wne 2648   E!wreu 2801   {crab 2803   {csn 3988   class class class wbr 4403   ` cfv 5529   iota_crio 6163  (class class class)co 6203   CCcc 9395   RRcr 9396   0cc0 9397    x. cmul 9402    < clt 9533    - cmin 9710    / cdiv 10108   NNcn 10437   NN0cn0 10694   ZZcz 10761   RR+crp 11106   |_cfl 11761    mod cmo 11829    || cdivides 13657
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1592  ax-4 1603  ax-5 1671  ax-6 1710  ax-7 1730  ax-8 1760  ax-9 1762  ax-10 1777  ax-11 1782  ax-12 1794  ax-13 1955  ax-ext 2432  ax-sep 4524  ax-nul 4532  ax-pow 4581  ax-pr 4642  ax-un 6485  ax-cnex 9453  ax-resscn 9454  ax-1cn 9455  ax-icn 9456  ax-addcl 9457  ax-addrcl 9458  ax-mulcl 9459  ax-mulrcl 9460  ax-mulcom 9461  ax-addass 9462  ax-mulass 9463  ax-distr 9464  ax-i2m1 9465  ax-1ne0 9466  ax-1rid 9467  ax-rnegex 9468  ax-rrecex 9469  ax-cnre 9470  ax-pre-lttri 9471  ax-pre-lttrn 9472  ax-pre-ltadd 9473  ax-pre-mulgt0 9474  ax-pre-sup 9475
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-tru 1373  df-ex 1588  df-nf 1591  df-sb 1703  df-eu 2266  df-mo 2267  df-clab 2440  df-cleq 2446  df-clel 2449  df-nfc 2604  df-ne 2650  df-nel 2651  df-ral 2804  df-rex 2805  df-reu 2806  df-rmo 2807  df-rab 2808  df-v 3080  df-sbc 3295  df-csb 3399  df-dif 3442  df-un 3444  df-in 3446  df-ss 3453  df-pss 3455  df-nul 3749  df-if 3903  df-pw 3973  df-sn 3989  df-pr 3991  df-tp 3993  df-op 3995  df-uni 4203  df-iun 4284  df-br 4404  df-opab 4462  df-mpt 4463  df-tr 4497  df-eprel 4743  df-id 4747  df-po 4752  df-so 4753  df-fr 4790  df-we 4792  df-ord 4833  df-on 4834  df-lim 4835  df-suc 4836  df-xp 4957  df-rel 4958  df-cnv 4959  df-co 4960  df-dm 4961  df-rn 4962  df-res 4963  df-ima 4964  df-iota 5492  df-fun 5531  df-fn 5532  df-f 5533  df-f1 5534  df-fo 5535  df-f1o 5536  df-fv 5537  df-riota 6164  df-ov 6206  df-oprab 6207  df-mpt2 6208  df-om 6590  df-1st 6690  df-2nd 6691  df-recs 6945  df-rdg 6979  df-er 7214  df-en 7424  df-dom 7425  df-sdom 7426  df-sup 7806  df-pnf 9535  df-mnf 9536  df-xr 9537  df-ltxr 9538  df-le 9539  df-sub 9712  df-neg 9713  df-div 10109  df-nn 10438  df-2 10495  df-3 10496  df-n0 10695  df-z 10762  df-uz 10977  df-rp 11107  df-fz 11559  df-fl 11763  df-mod 11830  df-seq 11928  df-exp 11987  df-cj 12710  df-re 12711  df-im 12712  df-sqr 12846  df-abs 12847  df-dvds 13658
This theorem is referenced by:  divalgmodcl  29507
  Copyright terms: Public domain W3C validator