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

Theorem divalgmod 13940
Description: The result of the  mod operator satisfies the requirements for the remainder  r in the division algorithm for a positive divisor (compare divalg2 13939 and divalgb 13938). 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 10880 . . . . . . . 8  |-  ( N  e.  ZZ  ->  N  e.  RR )
2 nnrp 11241 . . . . . . . 8  |-  ( D  e.  NN  ->  D  e.  RR+ )
3 modlt 11986 . . . . . . . 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 10555 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  RR )
6 nnne0 10580 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  =/=  0 )
7 redivcl 10275 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR  /\  D  =/=  0 )  ->  ( N  /  D )  e.  RR )
81, 5, 6, 7syl3an 1270 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN  /\  D  e.  NN )  ->  ( N  /  D )  e.  RR )
983anidm23 1287 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  /  D
)  e.  RR )
109flcld 11915 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  ZZ )
11 nnz 10898 . . . . . . . . 9  |-  ( D  e.  NN  ->  D  e.  ZZ )
1211adantl 466 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  ZZ )
13 zmodcl 11995 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  NN0 )
1413nn0zd 10976 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  ZZ )
15 zsubcl 10917 . . . . . . . . 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 10556 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  CC )
1817adantl 466 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  CC )
1910zcnd 10979 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  CC )
2018, 19mulcomd 9629 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( ( |_
`  ( N  /  D ) )  x.  D ) )
21 modval 11978 . . . . . . . . . . 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 10881 . . . . . . . . . . . . 13  |-  ( N  e.  ZZ  ->  N  e.  CC )
2423adantr 465 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  CC )
25 zmulcl 10923 . . . . . . . . . . . . . . 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 819 . . . . . . . . . . . . 13  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2827zcnd 10979 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC )
2913nn0cnd 10866 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  CC )
30 subsub23 9837 . . . . . . . . . . . 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 1228 . . . . . . . . . . 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 2476 . . . . . . . . . . 11  |-  ( ( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) )  =  ( N  mod  D )  <->  ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
33 eqcom 2476 . . . . . . . . . . 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 2510 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )
37 dvds0lem 13872 . . . . . . . 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 1231 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
39 divalg2 13939 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )
40 breq1 4456 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( z  <  D  <->  ( N  mod  D )  <  D ) )
41 oveq2 6303 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( N  -  z )  =  ( N  -  ( N  mod  D ) ) )
4241breq2d 4465 . . . . . . . . . 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 6279 . . . . . . . 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 919 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) )
4746eqcomd 2475 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z
) ) ) )
4847sneqd 4045 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
49 snriota 6286 . . . . 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 2511 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } )
5251eleq2d 2537 . 2  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  e.  {
( N  mod  D
) }  <->  r  e.  { z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
53 elsn 4047 . 2  |-  ( r  e.  { ( N  mod  D ) }  <-> 
r  =  ( N  mod  D ) )
54 breq1 4456 . . . 4  |-  ( z  =  r  ->  (
z  <  D  <->  r  <  D ) )
55 oveq2 6303 . . . . 5  |-  ( z  =  r  ->  ( N  -  z )  =  ( N  -  r ) )
5655breq2d 4465 . . . 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 3266 . 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 1379    e. wcel 1767    =/= wne 2662   E!wreu 2819   {crab 2821   {csn 4033   class class class wbr 4453   ` cfv 5594   iota_crio 6255  (class class class)co 6295   CCcc 9502   RRcr 9503   0cc0 9504    x. cmul 9509    < clt 9640    - cmin 9817    / cdiv 10218   NNcn 10548   NN0cn0 10807   ZZcz 10876   RR+crp 11232   |_cfl 11907    mod cmo 11976    || cdivides 13864
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1601  ax-4 1612  ax-5 1680  ax-6 1719  ax-7 1739  ax-8 1769  ax-9 1771  ax-10 1786  ax-11 1791  ax-12 1803  ax-13 1968  ax-ext 2445  ax-sep 4574  ax-nul 4582  ax-pow 4631  ax-pr 4692  ax-un 6587  ax-cnex 9560  ax-resscn 9561  ax-1cn 9562  ax-icn 9563  ax-addcl 9564  ax-addrcl 9565  ax-mulcl 9566  ax-mulrcl 9567  ax-mulcom 9568  ax-addass 9569  ax-mulass 9570  ax-distr 9571  ax-i2m1 9572  ax-1ne0 9573  ax-1rid 9574  ax-rnegex 9575  ax-rrecex 9576  ax-cnre 9577  ax-pre-lttri 9578  ax-pre-lttrn 9579  ax-pre-ltadd 9580  ax-pre-mulgt0 9581  ax-pre-sup 9582
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 974  df-3an 975  df-tru 1382  df-ex 1597  df-nf 1600  df-sb 1712  df-eu 2279  df-mo 2280  df-clab 2453  df-cleq 2459  df-clel 2462  df-nfc 2617  df-ne 2664  df-nel 2665  df-ral 2822  df-rex 2823  df-reu 2824  df-rmo 2825  df-rab 2826  df-v 3120  df-sbc 3337  df-csb 3441  df-dif 3484  df-un 3486  df-in 3488  df-ss 3495  df-pss 3497  df-nul 3791  df-if 3946  df-pw 4018  df-sn 4034  df-pr 4036  df-tp 4038  df-op 4040  df-uni 4252  df-iun 4333  df-br 4454  df-opab 4512  df-mpt 4513  df-tr 4547  df-eprel 4797  df-id 4801  df-po 4806  df-so 4807  df-fr 4844  df-we 4846  df-ord 4887  df-on 4888  df-lim 4889  df-suc 4890  df-xp 5011  df-rel 5012  df-cnv 5013  df-co 5014  df-dm 5015  df-rn 5016  df-res 5017  df-ima 5018  df-iota 5557  df-fun 5596  df-fn 5597  df-f 5598  df-f1 5599  df-fo 5600  df-f1o 5601  df-fv 5602  df-riota 6256  df-ov 6298  df-oprab 6299  df-mpt2 6300  df-om 6696  df-1st 6795  df-2nd 6796  df-recs 7054  df-rdg 7088  df-er 7323  df-en 7529  df-dom 7530  df-sdom 7531  df-sup 7913  df-pnf 9642  df-mnf 9643  df-xr 9644  df-ltxr 9645  df-le 9646  df-sub 9819  df-neg 9820  df-div 10219  df-nn 10549  df-2 10606  df-3 10607  df-n0 10808  df-z 10877  df-uz 11095  df-rp 11233  df-fz 11685  df-fl 11909  df-mod 11977  df-seq 12088  df-exp 12147  df-cj 12912  df-re 12913  df-im 12914  df-sqrt 13048  df-abs 13049  df-dvds 13865
This theorem is referenced by:  divalgmodcl  30857
  Copyright terms: Public domain W3C validator