ILE Home Intuitionistic Logic Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  ILE Home  >  Th. List  >  divalgmod Unicode version

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

Proof of Theorem divalgmod
Dummy variable  z is distinct from all other variables.
StepHypRef Expression
1 zq 8792 . . . . . . . 8  |-  ( N  e.  ZZ  ->  N  e.  QQ )
21adantr 270 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  QQ )
3 nnq 8799 . . . . . . . 8  |-  ( D  e.  NN  ->  D  e.  QQ )
43adantl 271 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  QQ )
5 simpr 108 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  NN )
65nngt0d 8149 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  0  <  D )
72, 4, 6modqcld 9410 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  QQ )
8 snidg 3431 . . . . . 6  |-  ( ( N  mod  D )  e.  QQ  ->  ( N  mod  D )  e. 
{ ( N  mod  D ) } )
97, 8syl 14 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  { ( N  mod  D ) } )
10 eleq1 2142 . . . . 5  |-  ( R  =  ( N  mod  D )  ->  ( R  e.  { ( N  mod  D ) }  <->  ( N  mod  D )  e.  {
( N  mod  D
) } ) )
119, 10syl5ibrcom 155 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  =  ( N  mod  D )  ->  R  e.  {
( N  mod  D
) } ) )
12 elsni 3424 . . . 4  |-  ( R  e.  { ( N  mod  D ) }  ->  R  =  ( N  mod  D ) )
1311, 12impbid1 140 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  =  ( N  mod  D )  <-> 
R  e.  { ( N  mod  D ) } ) )
14 modqlt 9415 . . . . . . . . 9  |-  ( ( N  e.  QQ  /\  D  e.  QQ  /\  0  <  D )  ->  ( N  mod  D )  < 
D )
152, 4, 6, 14syl3anc 1170 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  <  D )
16 znq 8790 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  /  D
)  e.  QQ )
1716flqcld 9359 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  ZZ )
18 nnz 8451 . . . . . . . . . 10  |-  ( D  e.  NN  ->  D  e.  ZZ )
1918adantl 271 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  ZZ )
20 zmodcl 9426 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  NN0 )
2120nn0zd 8548 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  ZZ )
22 zsubcl 8473 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  ( N  mod  D )  e.  ZZ )  -> 
( N  -  ( N  mod  D ) )  e.  ZZ )
2321, 22syldan 276 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  -  ( N  mod  D ) )  e.  ZZ )
24 nncn 8114 . . . . . . . . . . . 12  |-  ( D  e.  NN  ->  D  e.  CC )
2524adantl 271 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  CC )
2617zcnd 8551 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  CC )
2725, 26mulcomd 7202 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( ( |_
`  ( N  /  D ) )  x.  D ) )
28 modqval 9406 . . . . . . . . . . . 12  |-  ( ( N  e.  QQ  /\  D  e.  QQ  /\  0  <  D )  ->  ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) ) )
292, 4, 6, 28syl3anc 1170 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
3020nn0cnd 8410 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  CC )
31 zmulcl 8485 . . . . . . . . . . . . . 14  |-  ( ( D  e.  ZZ  /\  ( |_ `  ( N  /  D ) )  e.  ZZ )  -> 
( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
3218, 17, 31syl2an2 559 . . . . . . . . . . . . 13  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
3332zcnd 8551 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC )
34 zcn 8437 . . . . . . . . . . . . 13  |-  ( N  e.  ZZ  ->  N  e.  CC )
3534adantr 270 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  CC )
3630, 33, 35subexsub 7543 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) )  <->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) ) )
3729, 36mpbid 145 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3827, 37eqtr3d 2116 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )
39 dvds0lem 10350 . . . . . . . . 9  |-  ( ( ( ( |_ `  ( 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 ) ) )
4017, 19, 23, 38, 39syl31anc 1173 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
41 divalg2 10470 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )
42 breq1 3796 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( z  <  D  <->  ( N  mod  D )  <  D ) )
43 oveq2 5551 . . . . . . . . . . . 12  |-  ( z  =  ( N  mod  D )  ->  ( N  -  z )  =  ( N  -  ( N  mod  D ) ) )
4443breq2d 3805 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( D  ||  ( N  -  z
)  <->  D  ||  ( N  -  ( N  mod  D ) ) ) )
4542, 44anbi12d 457 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( (
z  <  D  /\  D  ||  ( N  -  z ) )  <->  ( ( N  mod  D )  < 
D  /\  D  ||  ( N  -  ( N  mod  D ) ) ) ) )
4645riota2 5521 . . . . . . . . 9  |-  ( ( ( 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
) ) )
4720, 41, 46syl2anc 403 . . . . . . . 8  |-  ( ( 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 ) ) )
4815, 40, 47mpbi2and 885 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) )
4948eqcomd 2087 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z
) ) ) )
5049sneqd 3419 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
51 snriota 5528 . . . . . 6  |-  ( 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 ) ) ) } )
5241, 51syl 14 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { z  e.  NN0  |  ( z  <  D  /\  D  ||  ( N  -  z ) ) }  =  { (
iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
5350, 52eqtr4d 2117 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } )
5453eleq2d 2149 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  e.  {
( N  mod  D
) }  <->  R  e.  { z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
5513, 54bitrd 186 . 2  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  =  ( N  mod  D )  <-> 
R  e.  { z  e.  NN0  |  (
z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
56 breq1 3796 . . . 4  |-  ( z  =  R  ->  (
z  <  D  <->  R  <  D ) )
57 oveq2 5551 . . . . 5  |-  ( z  =  R  ->  ( N  -  z )  =  ( N  -  R ) )
5857breq2d 3805 . . . 4  |-  ( z  =  R  ->  ( D  ||  ( N  -  z )  <->  D  ||  ( N  -  R )
) )
5956, 58anbi12d 457 . . 3  |-  ( z  =  R  ->  (
( z  <  D  /\  D  ||  ( N  -  z ) )  <-> 
( R  <  D  /\  D  ||  ( N  -  R ) ) ) )
6059elrab 2750 . 2  |-  ( R  e.  { z  e. 
NN0  |  ( z  <  D  /\  D  ||  ( N  -  z
) ) }  <->  ( R  e.  NN0  /\  ( R  <  D  /\  D  ||  ( N  -  R
) ) ) )
6155, 60syl6bb 194 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    /\ wa 102    <-> wb 103    = wceq 1285    e. wcel 1434   E!wreu 2351   {crab 2353   {csn 3406   class class class wbr 3793   ` cfv 4932   iota_crio 5498  (class class class)co 5543   CCcc 7041   0cc0 7043    x. cmul 7048    < clt 7215    - cmin 7346    / cdiv 7827   NNcn 8106   NN0cn0 8355   ZZcz 8432   QQcq 8785   |_cfl 9350    mod cmo 9404    || cdvds 10340
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-mp 7  ax-ia1 104  ax-ia2 105  ax-ia3 106  ax-in1 577  ax-in2 578  ax-io 663  ax-5 1377  ax-7 1378  ax-gen 1379  ax-ie1 1423  ax-ie2 1424  ax-8 1436  ax-10 1437  ax-11 1438  ax-i12 1439  ax-bndl 1440  ax-4 1441  ax-13 1445  ax-14 1446  ax-17 1460  ax-i9 1464  ax-ial 1468  ax-i5r 1469  ax-ext 2064  ax-coll 3901  ax-sep 3904  ax-nul 3912  ax-pow 3956  ax-pr 3972  ax-un 4196  ax-setind 4288  ax-iinf 4337  ax-cnex 7129  ax-resscn 7130  ax-1cn 7131  ax-1re 7132  ax-icn 7133  ax-addcl 7134  ax-addrcl 7135  ax-mulcl 7136  ax-mulrcl 7137  ax-addcom 7138  ax-mulcom 7139  ax-addass 7140  ax-mulass 7141  ax-distr 7142  ax-i2m1 7143  ax-0lt1 7144  ax-1rid 7145  ax-0id 7146  ax-rnegex 7147  ax-precex 7148  ax-cnre 7149  ax-pre-ltirr 7150  ax-pre-ltwlin 7151  ax-pre-lttrn 7152  ax-pre-apti 7153  ax-pre-ltadd 7154  ax-pre-mulgt0 7155  ax-pre-mulext 7156  ax-arch 7157
This theorem depends on definitions:  df-bi 115  df-dc 777  df-3or 921  df-3an 922  df-tru 1288  df-fal 1291  df-nf 1391  df-sb 1687  df-eu 1945  df-mo 1946  df-clab 2069  df-cleq 2075  df-clel 2078  df-nfc 2209  df-ne 2247  df-nel 2341  df-ral 2354  df-rex 2355  df-reu 2356  df-rmo 2357  df-rab 2358  df-v 2604  df-sbc 2817  df-csb 2910  df-dif 2976  df-un 2978  df-in 2980  df-ss 2987  df-nul 3259  df-if 3360  df-pw 3392  df-sn 3412  df-pr 3413  df-op 3415  df-uni 3610  df-int 3645  df-iun 3688  df-br 3794  df-opab 3848  df-mpt 3849  df-tr 3884  df-id 4056  df-po 4059  df-iso 4060  df-iord 4129  df-on 4131  df-ilim 4132  df-suc 4134  df-iom 4340  df-xp 4377  df-rel 4378  df-cnv 4379  df-co 4380  df-dm 4381  df-rn 4382  df-res 4383  df-ima 4384  df-iota 4897  df-fun 4934  df-fn 4935  df-f 4936  df-f1 4937  df-fo 4938  df-f1o 4939  df-fv 4940  df-riota 5499  df-ov 5546  df-oprab 5547  df-mpt2 5548  df-1st 5798  df-2nd 5799  df-recs 5954  df-frec 6040  df-pnf 7217  df-mnf 7218  df-xr 7219  df-ltxr 7220  df-le 7221  df-sub 7348  df-neg 7349  df-reap 7742  df-ap 7749  df-div 7828  df-inn 8107  df-2 8165  df-n0 8356  df-z 8433  df-uz 8701  df-q 8786  df-rp 8816  df-fl 9352  df-mod 9405  df-iseq 9522  df-iexp 9573  df-cj 9867  df-re 9868  df-im 9869  df-rsqrt 10022  df-abs 10023  df-dvds 10341
This theorem is referenced by:  divalgmodcl  10472
  Copyright terms: Public domain W3C validator