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

Theorem divalgmod 14387
Description: The result of the  mod operator satisfies the requirements for the remainder  r in the division algorithm for a positive divisor (compare divalg2 14386 and divalgb 14385). 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 10941 . . . . . . . 8  |-  ( N  e.  ZZ  ->  N  e.  RR )
2 nnrp 11311 . . . . . . . 8  |-  ( D  e.  NN  ->  D  e.  RR+ )
3 modlt 12107 . . . . . . . 8  |-  ( ( N  e.  RR  /\  D  e.  RR+ )  -> 
( N  mod  D
)  <  D )
41, 2, 3syl2an 480 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  <  D )
5 nnre 10616 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  RR )
6 nnne0 10642 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  =/=  0 )
7 redivcl 10326 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR  /\  D  =/=  0 )  ->  ( N  /  D )  e.  RR )
81, 5, 6, 7syl3an 1310 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN  /\  D  e.  NN )  ->  ( N  /  D )  e.  RR )
983anidm23 1327 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  /  D
)  e.  RR )
109flcld 12034 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  ZZ )
11 nnz 10959 . . . . . . . . 9  |-  ( D  e.  NN  ->  D  e.  ZZ )
1211adantl 468 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  ZZ )
13 zmodcl 12116 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  NN0 )
1413nn0zd 11038 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  ZZ )
15 zsubcl 10979 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  ( N  mod  D )  e.  ZZ )  -> 
( N  -  ( N  mod  D ) )  e.  ZZ )
1614, 15syldan 473 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  -  ( N  mod  D ) )  e.  ZZ )
17 nncn 10617 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  CC )
1817adantl 468 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  CC )
1910zcnd 11041 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  CC )
2018, 19mulcomd 9664 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( ( |_
`  ( N  /  D ) )  x.  D ) )
21 modval 12098 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR+ )  -> 
( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
221, 2, 21syl2an 480 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
23 zcn 10942 . . . . . . . . . . . . 13  |-  ( N  e.  ZZ  ->  N  e.  CC )
2423adantr 467 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  CC )
25 zmulcl 10985 . . . . . . . . . . . . . . 15  |-  ( ( D  e.  ZZ  /\  ( |_ `  ( N  /  D ) )  e.  ZZ )  -> 
( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2611, 10, 25syl2an 480 . . . . . . . . . . . . . 14  |-  ( ( D  e.  NN  /\  ( N  e.  ZZ  /\  D  e.  NN ) )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2726anabss7 830 . . . . . . . . . . . . 13  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2827zcnd 11041 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC )
2913nn0cnd 10927 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  CC )
30 subsub23 9880 . . . . . . . . . . . 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 1268 . . . . . . . . . . 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 2458 . . . . . . . . . . 11  |-  ( ( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) )  =  ( N  mod  D )  <->  ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
33 eqcom 2458 . . . . . . . . . . 11  |-  ( ( N  -  ( N  mod  D ) )  =  ( D  x.  ( |_ `  ( N  /  D ) ) )  <->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3431, 32, 333bitr3g 291 . . . . . . . . . 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 214 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3620, 35eqtr3d 2487 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )
37 dvds0lem 14313 . . . . . . . 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 1271 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
39 divalg2 14386 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )
40 breq1 4405 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( z  <  D  <->  ( N  mod  D )  <  D ) )
41 oveq2 6298 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( N  -  z )  =  ( N  -  ( N  mod  D ) ) )
4241breq2d 4414 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( D  ||  ( N  -  z
)  <->  D  ||  ( N  -  ( N  mod  D ) ) ) )
4340, 42anbi12d 717 . . . . . . . . 9  |-  ( z  =  ( N  mod  D )  ->  ( (
z  <  D  /\  D  ||  ( N  -  z ) )  <->  ( ( N  mod  D )  < 
D  /\  D  ||  ( N  -  ( N  mod  D ) ) ) ) )
4443riota2 6274 . . . . . . . 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 667 . . . . . . 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 932 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) )
4746eqcomd 2457 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z
) ) ) )
4847sneqd 3980 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
49 snriota 6281 . . . . 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 17 . . . 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 2488 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } )
5251eleq2d 2514 . 2  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  e.  {
( N  mod  D
) }  <->  r  e.  { z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
53 elsn 3982 . 2  |-  ( r  e.  { ( N  mod  D ) }  <-> 
r  =  ( N  mod  D ) )
54 breq1 4405 . . . 4  |-  ( z  =  r  ->  (
z  <  D  <->  r  <  D ) )
55 oveq2 6298 . . . . 5  |-  ( z  =  r  ->  ( N  -  z )  =  ( N  -  r ) )
5655breq2d 4414 . . . 4  |-  ( z  =  r  ->  ( D  ||  ( N  -  z )  <->  D  ||  ( N  -  r )
) )
5754, 56anbi12d 717 . . 3  |-  ( z  =  r  ->  (
( z  <  D  /\  D  ||  ( N  -  z ) )  <-> 
( r  <  D  /\  D  ||  ( N  -  r ) ) ) )
5857elrab 3196 . 2  |-  ( r  e.  { z  e. 
NN0  |  ( z  <  D  /\  D  ||  ( N  -  z
) ) }  <->  ( r  e.  NN0  /\  ( r  <  D  /\  D  ||  ( N  -  r
) ) ) )
5952, 53, 583bitr3g 291 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 188    /\ wa 371    = wceq 1444    e. wcel 1887    =/= wne 2622   E!wreu 2739   {crab 2741   {csn 3968   class class class wbr 4402   ` cfv 5582   iota_crio 6251  (class class class)co 6290   CCcc 9537   RRcr 9538   0cc0 9539    x. cmul 9544    < clt 9675    - cmin 9860    / cdiv 10269   NNcn 10609   NN0cn0 10869   ZZcz 10937   RR+crp 11302   |_cfl 12026    mod cmo 12096    || cdvds 14305
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1669  ax-4 1682  ax-5 1758  ax-6 1805  ax-7 1851  ax-8 1889  ax-9 1896  ax-10 1915  ax-11 1920  ax-12 1933  ax-13 2091  ax-ext 2431  ax-sep 4525  ax-nul 4534  ax-pow 4581  ax-pr 4639  ax-un 6583  ax-cnex 9595  ax-resscn 9596  ax-1cn 9597  ax-icn 9598  ax-addcl 9599  ax-addrcl 9600  ax-mulcl 9601  ax-mulrcl 9602  ax-mulcom 9603  ax-addass 9604  ax-mulass 9605  ax-distr 9606  ax-i2m1 9607  ax-1ne0 9608  ax-1rid 9609  ax-rnegex 9610  ax-rrecex 9611  ax-cnre 9612  ax-pre-lttri 9613  ax-pre-lttrn 9614  ax-pre-ltadd 9615  ax-pre-mulgt0 9616  ax-pre-sup 9617
This theorem depends on definitions:  df-bi 189  df-or 372  df-an 373  df-3or 986  df-3an 987  df-tru 1447  df-ex 1664  df-nf 1668  df-sb 1798  df-eu 2303  df-mo 2304  df-clab 2438  df-cleq 2444  df-clel 2447  df-nfc 2581  df-ne 2624  df-nel 2625  df-ral 2742  df-rex 2743  df-reu 2744  df-rmo 2745  df-rab 2746  df-v 3047  df-sbc 3268  df-csb 3364  df-dif 3407  df-un 3409  df-in 3411  df-ss 3418  df-pss 3420  df-nul 3732  df-if 3882  df-pw 3953  df-sn 3969  df-pr 3971  df-tp 3973  df-op 3975  df-uni 4199  df-iun 4280  df-br 4403  df-opab 4462  df-mpt 4463  df-tr 4498  df-eprel 4745  df-id 4749  df-po 4755  df-so 4756  df-fr 4793  df-we 4795  df-xp 4840  df-rel 4841  df-cnv 4842  df-co 4843  df-dm 4844  df-rn 4845  df-res 4846  df-ima 4847  df-pred 5380  df-ord 5426  df-on 5427  df-lim 5428  df-suc 5429  df-iota 5546  df-fun 5584  df-fn 5585  df-f 5586  df-f1 5587  df-fo 5588  df-f1o 5589  df-fv 5590  df-riota 6252  df-ov 6293  df-oprab 6294  df-mpt2 6295  df-om 6693  df-1st 6793  df-2nd 6794  df-wrecs 7028  df-recs 7090  df-rdg 7128  df-er 7363  df-en 7570  df-dom 7571  df-sdom 7572  df-sup 7956  df-inf 7957  df-pnf 9677  df-mnf 9678  df-xr 9679  df-ltxr 9680  df-le 9681  df-sub 9862  df-neg 9863  df-div 10270  df-nn 10610  df-2 10668  df-3 10669  df-n0 10870  df-z 10938  df-uz 11160  df-rp 11303  df-fz 11785  df-fl 12028  df-mod 12097  df-seq 12214  df-exp 12273  df-cj 13162  df-re 13163  df-im 13164  df-sqrt 13298  df-abs 13299  df-dvds 14306
This theorem is referenced by:  divalgmodcl  35842
  Copyright terms: Public domain W3C validator