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

Theorem divalg 14268
Description: The division algorithm (theorem). Dividing an integer  N by a nonzero integer  D produces a (unique) quotient  q and a unique remainder  0  <_  r  <  ( abs `  D
). The proof does not use  /,  |_ or  mod. (Contributed by Paul Chapman, 21-Mar-2011.)
Assertion
Ref Expression
divalg  |-  ( ( N  e.  ZZ  /\  D  e.  ZZ  /\  D  =/=  0 )  ->  E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  N  =  ( ( q  x.  D
)  +  r ) ) )
Distinct variable groups:    D, q,
r    N, q, r

Proof of Theorem divalg
StepHypRef Expression
1 eqeq1 2406 . . . . . 6  |-  ( N  =  if ( N  e.  ZZ ,  N ,  1 )  -> 
( N  =  ( ( q  x.  D
)  +  r )  <-> 
if ( N  e.  ZZ ,  N , 
1 )  =  ( ( q  x.  D
)  +  r ) ) )
213anbi3d 1307 . . . . 5  |-  ( N  =  if ( N  e.  ZZ ,  N ,  1 )  -> 
( ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  N  =  ( ( q  x.  D
)  +  r ) )  <->  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r ) ) ) )
32rexbidv 2917 . . . 4  |-  ( N  =  if ( N  e.  ZZ ,  N ,  1 )  -> 
( E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  N  =  ( ( q  x.  D
)  +  r ) )  <->  E. q  e.  ZZ  ( 0  <_  r  /\  r  <  ( abs `  D )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r ) ) ) )
43reubidv 2991 . . 3  |-  ( N  =  if ( N  e.  ZZ ,  N ,  1 )  -> 
( E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  N  =  ( ( q  x.  D
)  +  r ) )  <->  E! r  e.  ZZ  E. q  e.  ZZ  (
0  <_  r  /\  r  <  ( abs `  D
)  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r ) ) ) )
5 fveq2 5848 . . . . . . 7  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( abs `  D
)  =  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) ) )
65breq2d 4406 . . . . . 6  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( r  < 
( abs `  D
)  <->  r  <  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) ) ) )
7 oveq2 6285 . . . . . . . 8  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( q  x.  D )  =  ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) ) )
87oveq1d 6292 . . . . . . 7  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( ( q  x.  D )  +  r )  =  ( ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  +  r ) )
98eqeq2d 2416 . . . . . 6  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r )  <->  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  +  r ) ) )
106, 93anbi23d 1304 . . . . 5  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( ( 0  <_  r  /\  r  <  ( abs `  D
)  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r ) )  <->  ( 0  <_  r  /\  r  <  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  +  r ) ) ) )
1110rexbidv 2917 . . . 4  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r ) )  <->  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  +  r ) ) ) )
1211reubidv 2991 . . 3  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  D )  +  r ) )  <->  E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  +  r ) ) ) )
13 1z 10934 . . . . 5  |-  1  e.  ZZ
1413elimel 3946 . . . 4  |-  if ( N  e.  ZZ ,  N ,  1 )  e.  ZZ
15 simpl 455 . . . . 5  |-  ( ( D  e.  ZZ  /\  D  =/=  0 )  ->  D  e.  ZZ )
16 eleq1 2474 . . . . 5  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( D  e.  ZZ  <->  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  e.  ZZ ) )
17 eleq1 2474 . . . . 5  |-  ( 1  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( 1  e.  ZZ  <->  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  e.  ZZ ) )
1815, 16, 17, 13elimdhyp 3947 . . . 4  |-  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  e.  ZZ
19 simpr 459 . . . . 5  |-  ( ( D  e.  ZZ  /\  D  =/=  0 )  ->  D  =/=  0 )
20 neeq1 2684 . . . . 5  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( D  =/=  0  <->  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  =/=  0 ) )
21 neeq1 2684 . . . . 5  |-  ( 1  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( 1  =/=  0  <->  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  =/=  0 ) )
22 ax-1ne0 9590 . . . . 5  |-  1  =/=  0
2319, 20, 21, 22elimdhyp 3947 . . . 4  |-  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  =/=  0
24 eqid 2402 . . . 4  |-  { r  e.  NN0  |  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ||  ( if ( N  e.  ZZ ,  N , 
1 )  -  r
) }  =  {
r  e.  NN0  |  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ||  ( if ( N  e.  ZZ ,  N , 
1 )  -  r
) }
2514, 18, 23, 24divalglem10 14267 . . 3  |-  E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  /\  if ( N  e.  ZZ ,  N ,  1 )  =  ( ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) )  +  r ) )
264, 12, 25dedth2h 3936 . 2  |-  ( ( N  e.  ZZ  /\  ( D  e.  ZZ  /\  D  =/=  0 ) )  ->  E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  N  =  ( ( q  x.  D
)  +  r ) ) )
27263impb 1193 1  |-  ( ( N  e.  ZZ  /\  D  e.  ZZ  /\  D  =/=  0 )  ->  E! r  e.  ZZ  E. q  e.  ZZ  ( 0  <_ 
r  /\  r  <  ( abs `  D )  /\  N  =  ( ( q  x.  D
)  +  r ) ) )
Colors of variables: wff setvar class
Syntax hints:    -> wi 4    /\ wa 367    /\ w3a 974    = wceq 1405    e. wcel 1842    =/= wne 2598   E.wrex 2754   E!wreu 2755   {crab 2757   ifcif 3884   class class class wbr 4394   ` cfv 5568  (class class class)co 6277   0cc0 9521   1c1 9522    + caddc 9524    x. cmul 9526    < clt 9657    <_ cle 9658    - cmin 9840   NN0cn0 10835   ZZcz 10904   abscabs 13214    || cdvds 14193
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1639  ax-4 1652  ax-5 1725  ax-6 1771  ax-7 1814  ax-8 1844  ax-9 1846  ax-10 1861  ax-11 1866  ax-12 1878  ax-13 2026  ax-ext 2380  ax-sep 4516  ax-nul 4524  ax-pow 4571  ax-pr 4629  ax-un 6573  ax-cnex 9577  ax-resscn 9578  ax-1cn 9579  ax-icn 9580  ax-addcl 9581  ax-addrcl 9582  ax-mulcl 9583  ax-mulrcl 9584  ax-mulcom 9585  ax-addass 9586  ax-mulass 9587  ax-distr 9588  ax-i2m1 9589  ax-1ne0 9590  ax-1rid 9591  ax-rnegex 9592  ax-rrecex 9593  ax-cnre 9594  ax-pre-lttri 9595  ax-pre-lttrn 9596  ax-pre-ltadd 9597  ax-pre-mulgt0 9598  ax-pre-sup 9599
This theorem depends on definitions:  df-bi 185  df-or 368  df-an 369  df-3or 975  df-3an 976  df-tru 1408  df-ex 1634  df-nf 1638  df-sb 1764  df-eu 2242  df-mo 2243  df-clab 2388  df-cleq 2394  df-clel 2397  df-nfc 2552  df-ne 2600  df-nel 2601  df-ral 2758  df-rex 2759  df-reu 2760  df-rmo 2761  df-rab 2762  df-v 3060  df-sbc 3277  df-csb 3373  df-dif 3416  df-un 3418  df-in 3420  df-ss 3427  df-pss 3429  df-nul 3738  df-if 3885  df-pw 3956  df-sn 3972  df-pr 3974  df-tp 3976  df-op 3978  df-uni 4191  df-iun 4272  df-br 4395  df-opab 4453  df-mpt 4454  df-tr 4489  df-eprel 4733  df-id 4737  df-po 4743  df-so 4744  df-fr 4781  df-we 4783  df-xp 4828  df-rel 4829  df-cnv 4830  df-co 4831  df-dm 4832  df-rn 4833  df-res 4834  df-ima 4835  df-pred 5366  df-ord 5412  df-on 5413  df-lim 5414  df-suc 5415  df-iota 5532  df-fun 5570  df-fn 5571  df-f 5572  df-f1 5573  df-fo 5574  df-f1o 5575  df-fv 5576  df-riota 6239  df-ov 6280  df-oprab 6281  df-mpt2 6282  df-om 6683  df-1st 6783  df-2nd 6784  df-wrecs 7012  df-recs 7074  df-rdg 7112  df-er 7347  df-en 7554  df-dom 7555  df-sdom 7556  df-sup 7934  df-pnf 9659  df-mnf 9660  df-xr 9661  df-ltxr 9662  df-le 9663  df-sub 9842  df-neg 9843  df-div 10247  df-nn 10576  df-2 10634  df-3 10635  df-n0 10836  df-z 10905  df-uz 11127  df-rp 11265  df-fz 11725  df-seq 12150  df-exp 12209  df-cj 13079  df-re 13080  df-im 13081  df-sqrt 13215  df-abs 13216  df-dvds 14194
This theorem is referenced by:  divalg2  14270
  Copyright terms: Public domain W3C validator