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

Theorem divalgmod 11658
Description: The result of the  mod operator satisfies the requirements for the remainder  R in the division algorithm for a positive divisor (compare divalg2 11657 and divalgb 11656). 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 9444 . . . . . . . 8  |-  ( N  e.  ZZ  ->  N  e.  QQ )
21adantr 274 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  QQ )
3 nnq 9451 . . . . . . . 8  |-  ( D  e.  NN  ->  D  e.  QQ )
43adantl 275 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  QQ )
5 simpr 109 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  NN )
65nngt0d 8787 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  0  <  D )
72, 4, 6modqcld 10131 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  QQ )
8 snidg 3560 . . . . . 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 2203 . . . . 5  |-  ( R  =  ( N  mod  D )  ->  ( R  e.  { ( N  mod  D ) }  <->  ( N  mod  D )  e.  {
( N  mod  D
) } ) )
119, 10syl5ibrcom 156 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  =  ( N  mod  D )  ->  R  e.  {
( N  mod  D
) } ) )
12 elsni 3549 . . . 4  |-  ( R  e.  { ( N  mod  D ) }  ->  R  =  ( N  mod  D ) )
1311, 12impbid1 141 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  =  ( N  mod  D )  <-> 
R  e.  { ( N  mod  D ) } ) )
14 modqlt 10136 . . . . . . . . 9  |-  ( ( N  e.  QQ  /\  D  e.  QQ  /\  0  <  D )  ->  ( N  mod  D )  < 
D )
152, 4, 6, 14syl3anc 1217 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  <  D )
16 znq 9442 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  /  D
)  e.  QQ )
1716flqcld 10080 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  ZZ )
18 nnz 9096 . . . . . . . . . 10  |-  ( D  e.  NN  ->  D  e.  ZZ )
1918adantl 275 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  ZZ )
20 zmodcl 10147 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  NN0 )
2120nn0zd 9194 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  ZZ )
22 zsubcl 9118 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  ( N  mod  D )  e.  ZZ )  -> 
( N  -  ( N  mod  D ) )  e.  ZZ )
2321, 22syldan 280 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  -  ( N  mod  D ) )  e.  ZZ )
24 nncn 8751 . . . . . . . . . . . 12  |-  ( D  e.  NN  ->  D  e.  CC )
2524adantl 275 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  e.  CC )
2617zcnd 9197 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( |_ `  ( N  /  D ) )  e.  CC )
2725, 26mulcomd 7810 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( ( |_
`  ( N  /  D ) )  x.  D ) )
28 modqval 10127 . . . . . . . . . . . 12  |-  ( ( N  e.  QQ  /\  D  e.  QQ  /\  0  <  D )  ->  ( N  mod  D )  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D
) ) ) ) )
292, 4, 6, 28syl3anc 1217 . . . . . . . . . . 11  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( N  -  ( D  x.  ( |_ `  ( N  /  D ) ) ) ) )
3020nn0cnd 9055 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  e.  CC )
31 zmulcl 9130 . . . . . . . . . . . . . 14  |-  ( ( D  e.  ZZ  /\  ( |_ `  ( N  /  D ) )  e.  ZZ )  -> 
( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
3218, 17, 31syl2an2 584 . . . . . . . . . . . . 13  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  ZZ )
3332zcnd 9197 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  e.  CC )
34 zcn 9082 . . . . . . . . . . . . 13  |-  ( N  e.  ZZ  ->  N  e.  CC )
3534adantr 274 . . . . . . . . . . . 12  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  N  e.  CC )
3630, 33, 35subexsub 8157 . . . . . . . . . . 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 146 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( D  x.  ( |_ `  ( N  /  D ) ) )  =  ( N  -  ( N  mod  D ) ) )
3827, 37eqtr3d 2175 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( ( |_ `  ( N  /  D
) )  x.  D
)  =  ( N  -  ( N  mod  D ) ) )
39 dvds0lem 11537 . . . . . . . . 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 1220 . . . . . . . 8  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  D  ||  ( N  -  ( N  mod  D ) ) )
41 divalg2 11657 . . . . . . . . 9  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  E! z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )
42 breq1 3939 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( z  <  D  <->  ( N  mod  D )  <  D ) )
43 oveq2 5789 . . . . . . . . . . . 12  |-  ( z  =  ( N  mod  D )  ->  ( N  -  z )  =  ( N  -  ( N  mod  D ) ) )
4443breq2d 3948 . . . . . . . . . . 11  |-  ( z  =  ( N  mod  D )  ->  ( D  ||  ( N  -  z
)  <->  D  ||  ( N  -  ( N  mod  D ) ) ) )
4542, 44anbi12d 465 . . . . . . . . . 10  |-  ( z  =  ( N  mod  D )  ->  ( (
z  <  D  /\  D  ||  ( N  -  z ) )  <->  ( ( N  mod  D )  < 
D  /\  D  ||  ( N  -  ( N  mod  D ) ) ) ) )
4645riota2 5759 . . . . . . . . 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 409 . . . . . . . 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 928 . . . . . . 7  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) )  =  ( N  mod  D ) )
4948eqcomd 2146 . . . . . 6  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( N  mod  D
)  =  ( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z
) ) ) )
5049sneqd 3544 . . . . 5  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
( iota_ z  e.  NN0  ( z  <  D  /\  D  ||  ( N  -  z ) ) ) } )
51 snriota 5766 . . . . . 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 2176 . . . 4  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  { ( N  mod  D ) }  =  {
z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } )
5453eleq2d 2210 . . 3  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  e.  {
( N  mod  D
) }  <->  R  e.  { z  e.  NN0  | 
( z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
5513, 54bitrd 187 . 2  |-  ( ( N  e.  ZZ  /\  D  e.  NN )  ->  ( R  =  ( N  mod  D )  <-> 
R  e.  { z  e.  NN0  |  (
z  <  D  /\  D  ||  ( N  -  z ) ) } ) )
56 breq1 3939 . . . 4  |-  ( z  =  R  ->  (
z  <  D  <->  R  <  D ) )
57 oveq2 5789 . . . . 5  |-  ( z  =  R  ->  ( N  -  z )  =  ( N  -  R ) )
5857breq2d 3948 . . . 4  |-  ( z  =  R  ->  ( D  ||  ( N  -  z )  <->  D  ||  ( N  -  R )
) )
5956, 58anbi12d 465 . . 3  |-  ( z  =  R  ->  (
( z  <  D  /\  D  ||  ( N  -  z ) )  <-> 
( R  <  D  /\  D  ||  ( N  -  R ) ) ) )
6059elrab 2843 . 2  |-  ( R  e.  { z  e. 
NN0  |  ( z  <  D  /\  D  ||  ( N  -  z
) ) }  <->  ( R  e.  NN0  /\  ( R  <  D  /\  D  ||  ( N  -  R
) ) ) )
6155, 60syl6bb 195 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 103    <-> wb 104    = wceq 1332    e. wcel 1481   E!wreu 2419   {crab 2421   {csn 3531   class class class wbr 3936   ` cfv 5130   iota_crio 5736  (class class class)co 5781   CCcc 7641   0cc0 7643    x. cmul 7648    < clt 7823    - cmin 7956    / cdiv 8455   NNcn 8743   NN0cn0 9000   ZZcz 9077   QQcq 9437   |_cfl 10071    mod cmo 10125    || cdvds 11527
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-ia1 105  ax-ia2 106  ax-ia3 107  ax-in1 604  ax-in2 605  ax-io 699  ax-5 1424  ax-7 1425  ax-gen 1426  ax-ie1 1470  ax-ie2 1471  ax-8 1483  ax-10 1484  ax-11 1485  ax-i12 1486  ax-bndl 1487  ax-4 1488  ax-13 1492  ax-14 1493  ax-17 1507  ax-i9 1511  ax-ial 1515  ax-i5r 1516  ax-ext 2122  ax-coll 4050  ax-sep 4053  ax-nul 4061  ax-pow 4105  ax-pr 4138  ax-un 4362  ax-setind 4459  ax-iinf 4509  ax-cnex 7734  ax-resscn 7735  ax-1cn 7736  ax-1re 7737  ax-icn 7738  ax-addcl 7739  ax-addrcl 7740  ax-mulcl 7741  ax-mulrcl 7742  ax-addcom 7743  ax-mulcom 7744  ax-addass 7745  ax-mulass 7746  ax-distr 7747  ax-i2m1 7748  ax-0lt1 7749  ax-1rid 7750  ax-0id 7751  ax-rnegex 7752  ax-precex 7753  ax-cnre 7754  ax-pre-ltirr 7755  ax-pre-ltwlin 7756  ax-pre-lttrn 7757  ax-pre-apti 7758  ax-pre-ltadd 7759  ax-pre-mulgt0 7760  ax-pre-mulext 7761  ax-arch 7762
This theorem depends on definitions:  df-bi 116  df-dc 821  df-3or 964  df-3an 965  df-tru 1335  df-fal 1338  df-nf 1438  df-sb 1737  df-eu 2003  df-mo 2004  df-clab 2127  df-cleq 2133  df-clel 2136  df-nfc 2271  df-ne 2310  df-nel 2405  df-ral 2422  df-rex 2423  df-reu 2424  df-rmo 2425  df-rab 2426  df-v 2691  df-sbc 2913  df-csb 3007  df-dif 3077  df-un 3079  df-in 3081  df-ss 3088  df-nul 3368  df-if 3479  df-pw 3516  df-sn 3537  df-pr 3538  df-op 3540  df-uni 3744  df-int 3779  df-iun 3822  df-br 3937  df-opab 3997  df-mpt 3998  df-tr 4034  df-id 4222  df-po 4225  df-iso 4226  df-iord 4295  df-on 4297  df-ilim 4298  df-suc 4300  df-iom 4512  df-xp 4552  df-rel 4553  df-cnv 4554  df-co 4555  df-dm 4556  df-rn 4557  df-res 4558  df-ima 4559  df-iota 5095  df-fun 5132  df-fn 5133  df-f 5134  df-f1 5135  df-fo 5136  df-f1o 5137  df-fv 5138  df-riota 5737  df-ov 5784  df-oprab 5785  df-mpo 5786  df-1st 6045  df-2nd 6046  df-recs 6209  df-frec 6295  df-pnf 7825  df-mnf 7826  df-xr 7827  df-ltxr 7828  df-le 7829  df-sub 7958  df-neg 7959  df-reap 8360  df-ap 8367  df-div 8456  df-inn 8744  df-2 8802  df-n0 9001  df-z 9078  df-uz 9350  df-q 9438  df-rp 9470  df-fl 10073  df-mod 10126  df-seqfrec 10249  df-exp 10323  df-cj 10645  df-re 10646  df-im 10647  df-rsqrt 10801  df-abs 10802  df-dvds 11528
This theorem is referenced by:  divalgmodcl  11659
  Copyright terms: Public domain W3C validator