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

Theorem divalgmod 12928
Description: The result of the  mod operator satisfies the requirements for the remainder  r in the division algorithm for a positive divisor (compare divalg2 12927 and divalgb 12926). 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 10288 . . . . . . . 8  |-  ( N  e.  ZZ  ->  N  e.  RR )
2 nnrp 10623 . . . . . . . 8  |-  ( D  e.  NN  ->  D  e.  RR+ )
3 modlt 11260 . . . . . . . 8  |-  ( ( N  e.  RR  /\  D  e.  RR+ )  -> 
( N  mod  D
)  <  D )
41, 2, 3syl2an 465 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  <  D )
5 nnre 10009 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  RR )
6 nnne0 10034 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  =/=  0 )
7 redivcl 9735 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR  /\  D  =/=  0 )  ->  ( N  /  D )  e.  RR )
81, 5, 6, 7syl3an 1227 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN  /\  D  e.  NN )  ->  ( N  /  D )  e.  RR )
983anidm23 1244 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  /  D
)  e.  RR )
109flcld 11209 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  ZZ )
11 nnz 10305 . . . . . . . . 9  |-  ( D  e.  NN  ->  D  e.  ZZ )
1211adantl 454 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  ZZ )
13 zmodcl 11268 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  NN0 )
1413nn0zd 10375 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  ZZ )
15 zsubcl 10321 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  ( N  mod  D )  e.  ZZ )  -> 
( N  -  ( N  mod  D ) )  e.  ZZ )
1614, 15syldan 458 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  -  ( N  mod  D ) )  e.  ZZ )
17 nncn 10010 . . . . . . . . . . 11  |-  ( D  e.  NN  ->  D  e.  CC )
1817adantl 454 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  CC )
1910zcnd 10378 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  CC )
2018, 19mulcomd 9111 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( ( |_
`  ( N  /  D ) )  x.  D ) )
21 modval 11254 . . . . . . . . . . 11  |-  ( ( N  e.  RR  /\  D  e.  RR+ )  -> 
( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
221, 2, 21syl2an 465 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
23 zcn 10289 . . . . . . . . . . . . 13  |-  ( N  e.  ZZ  ->  N  e.  CC )
2423adantr 453 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  CC )
25 zmulcl 10326 . . . . . . . . . . . . . . 15  |-  ( ( D  e.  ZZ  /\  ( |_ `  ( N  /  D ) )  e.  ZZ )  -> 
( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2611, 10, 25syl2an 465 . . . . . . . . . . . . . 14  |-  ( ( D  e.  NN  /\  ( N  e.  ZZ  /\  D  e.  NN ) )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2726anabss7 796 . . . . . . . . . . . . 13  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
2827zcnd 10378 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC )
2913nn0cnd 10278 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  CC )
30 subsub23 9312 . . . . . . . . . . . 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 1185 . . . . . . . . . . 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 2440 . . . . . . . . . . 11  |-  ( ( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) )  =  ( N  mod  D )  <->  ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
33 eqcom 2440 . . . . . . . . . . 11  |-  ( ( N  -  ( N  mod  D ) )  =  ( D  x.  ( |_ `  ( N  /  D ) ) )  <->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3431, 32, 333bitr3g 280 . . . . . . . . . 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 203 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3620, 35eqtr3d 2472 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )
37 dvds0lem 12862 . . . . . . . 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 1188 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
39 divalg2 12927 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )
40 breq1 4217 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( z  <  D  <->  ( N  mod  D )  <  D ) )
41 oveq2 6091 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( N  -  z )  =  ( N  -  ( N  mod  D ) ) )
4241breq2d 4226 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( D  ||  ( N  -  z
)  <->  D  ||  ( N  -  ( N  mod  D ) ) ) )
4340, 42anbi12d 693 . . . . . . . . 9  |-  ( z  =  ( N  mod  D )  ->  ( (
z  <  D  /\  D  ||  ( N  -  z ) )  <->  ( ( N  mod  D )  < 
D  /\  D  ||  ( N  -  ( N  mod  D ) ) ) ) )
4443riota2 6574 . . . . . . . 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 644 . . . . . . 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 889 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( iota_ z  e.  NN0 ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) )
4746eqcomd 2443 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( iota_ z  e.  NN0 ( z  <  D  /\  D  ||  ( N  -  z
) ) ) )
4847sneqd 3829 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
( iota_ z  e.  NN0 ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
49 snriota 6582 . . . . 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 2473 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } )
5251eleq2d 2505 . 2  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  e.  {
( N  mod  D
) }  <->  r  e.  { z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
53 elsn 3831 . 2  |-  ( r  e.  { ( N  mod  D ) }  <-> 
r  =  ( N  mod  D ) )
54 breq1 4217 . . . 4  |-  ( z  =  r  ->  (
z  <  D  <->  r  <  D ) )
55 oveq2 6091 . . . . 5  |-  ( z  =  r  ->  ( N  -  z )  =  ( N  -  r ) )
5655breq2d 4226 . . . 4  |-  ( z  =  r  ->  ( D  ||  ( N  -  z )  <->  D  ||  ( N  -  r )
) )
5754, 56anbi12d 693 . . 3  |-  ( z  =  r  ->  (
( z  <  D  /\  D  ||  ( N  -  z ) )  <-> 
( r  <  D  /\  D  ||  ( N  -  r ) ) ) )
5857elrab 3094 . 2  |-  ( r  e.  { z  e. 
NN0  |  ( z  <  D  /\  D  ||  ( N  -  z
) ) }  <->  ( r  e.  NN0  /\  ( r  <  D  /\  D  ||  ( N  -  r
) ) ) )
5952, 53, 583bitr3g 280 1  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( r  =  ( N  mod  D )  <-> 
( r  e.  NN0  /\  ( r  <  D  /\  D  ||  ( N  -  r ) ) ) ) )
Colors of variables: wff set class
Syntax hints:    -> wi 4    <-> wb 178    /\ wa 360    = wceq 1653    e. wcel 1726    =/= wne 2601   E!wreu 2709   {crab 2711   {csn 3816   class class class wbr 4214   ` cfv 5456  (class class class)co 6083   iota_crio 6544   CCcc 8990   RRcr 8991   0cc0 8992    x. cmul 8997    < clt 9122    - cmin 9293    / cdiv 9679   NNcn 10002   NN0cn0 10223   ZZcz 10284   RR+crp 10614   |_cfl 11203    mod cmo 11252    || cdivides 12854
This theorem is referenced by:  divalgmodcl  27060
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1556  ax-5 1567  ax-17 1627  ax-9 1667  ax-8 1688  ax-13 1728  ax-14 1730  ax-6 1745  ax-7 1750  ax-11 1762  ax-12 1951  ax-ext 2419  ax-sep 4332  ax-nul 4340  ax-pow 4379  ax-pr 4405  ax-un 4703  ax-cnex 9048  ax-resscn 9049  ax-1cn 9050  ax-icn 9051  ax-addcl 9052  ax-addrcl 9053  ax-mulcl 9054  ax-mulrcl 9055  ax-mulcom 9056  ax-addass 9057  ax-mulass 9058  ax-distr 9059  ax-i2m1 9060  ax-1ne0 9061  ax-1rid 9062  ax-rnegex 9063  ax-rrecex 9064  ax-cnre 9065  ax-pre-lttri 9066  ax-pre-lttrn 9067  ax-pre-ltadd 9068  ax-pre-mulgt0 9069  ax-pre-sup 9070
This theorem depends on definitions:  df-bi 179  df-or 361  df-an 362  df-3or 938  df-3an 939  df-tru 1329  df-ex 1552  df-nf 1555  df-sb 1660  df-eu 2287  df-mo 2288  df-clab 2425  df-cleq 2431  df-clel 2434  df-nfc 2563  df-ne 2603  df-nel 2604  df-ral 2712  df-rex 2713  df-reu 2714  df-rmo 2715  df-rab 2716  df-v 2960  df-sbc 3164  df-csb 3254  df-dif 3325  df-un 3327  df-in 3329  df-ss 3336  df-pss 3338  df-nul 3631  df-if 3742  df-pw 3803  df-sn 3822  df-pr 3823  df-tp 3824  df-op 3825  df-uni 4018  df-iun 4097  df-br 4215  df-opab 4269  df-mpt 4270  df-tr 4305  df-eprel 4496  df-id 4500  df-po 4505  df-so 4506  df-fr 4543  df-we 4545  df-ord 4586  df-on 4587  df-lim 4588  df-suc 4589  df-om 4848  df-xp 4886  df-rel 4887  df-cnv 4888  df-co 4889  df-dm 4890  df-rn 4891  df-res 4892  df-ima 4893  df-iota 5420  df-fun 5458  df-fn 5459  df-f 5460  df-f1 5461  df-fo 5462  df-f1o 5463  df-fv 5464  df-ov 6086  df-oprab 6087  df-mpt2 6088  df-1st 6351  df-2nd 6352  df-riota 6551  df-recs 6635  df-rdg 6670  df-er 6907  df-en 7112  df-dom 7113  df-sdom 7114  df-sup 7448  df-pnf 9124  df-mnf 9125  df-xr 9126  df-ltxr 9127  df-le 9128  df-sub 9295  df-neg 9296  df-div 9680  df-nn 10003  df-2 10060  df-3 10061  df-n0 10224  df-z 10285  df-uz 10491  df-rp 10615  df-fz 11046  df-fl 11204  df-mod 11253  df-seq 11326  df-exp 11385  df-cj 11906  df-re 11907  df-im 11908  df-sqr 12042  df-abs 12043  df-dvds 12855
  Copyright terms: Public domain W3C validator