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

Theorem divalg 13607
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 2449 . . . . . 6  |-  ( N  =  if ( N  e.  ZZ ,  N ,  1 )  -> 
( N  =  ( ( q  x.  D
)  +  r )  <-> 
if ( N  e.  ZZ ,  N , 
1 )  =  ( ( q  x.  D
)  +  r ) ) )
213anbi3d 1295 . . . . 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 2736 . . . 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 2905 . . 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 5691 . . . . . . 7  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( abs `  D
)  =  ( abs `  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) ) )
65breq2d 4304 . . . . . 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 6099 . . . . . . . 8  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( q  x.  D )  =  ( q  x.  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 ) ) )
87oveq1d 6106 . . . . . . 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 2454 . . . . . 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 1292 . . . . 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 2736 . . . 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 2905 . . 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 10676 . . . . 5  |-  1  e.  ZZ
1413elimel 3852 . . . 4  |-  if ( N  e.  ZZ ,  N ,  1 )  e.  ZZ
15 simpl 457 . . . . 5  |-  ( ( D  e.  ZZ  /\  D  =/=  0 )  ->  D  e.  ZZ )
16 eleq1 2503 . . . . 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 2503 . . . . 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 3853 . . . 4  |-  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  e.  ZZ
19 simpr 461 . . . . 5  |-  ( ( D  e.  ZZ  /\  D  =/=  0 )  ->  D  =/=  0 )
20 neeq1 2616 . . . . 5  |-  ( D  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( D  =/=  0  <->  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  =/=  0 ) )
21 neeq1 2616 . . . . 5  |-  ( 1  =  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  ->  ( 1  =/=  0  <->  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  =/=  0 ) )
22 ax-1ne0 9351 . . . . 5  |-  1  =/=  0
2319, 20, 21, 22elimdhyp 3853 . . . 4  |-  if ( ( D  e.  ZZ  /\  D  =/=  0 ) ,  D ,  1 )  =/=  0
24 eqid 2443 . . . 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 13606 . . 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 3842 . 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 1183 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 369    /\ w3a 965    = wceq 1369    e. wcel 1756    =/= wne 2606   E.wrex 2716   E!wreu 2717   {crab 2719   ifcif 3791   class class class wbr 4292   ` cfv 5418  (class class class)co 6091   0cc0 9282   1c1 9283    + caddc 9285    x. cmul 9287    < clt 9418    <_ cle 9419    - cmin 9595   NN0cn0 10579   ZZcz 10646   abscabs 12723    || cdivides 13535
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1591  ax-4 1602  ax-5 1670  ax-6 1708  ax-7 1728  ax-8 1758  ax-9 1760  ax-10 1775  ax-11 1780  ax-12 1792  ax-13 1943  ax-ext 2423  ax-sep 4413  ax-nul 4421  ax-pow 4470  ax-pr 4531  ax-un 6372  ax-cnex 9338  ax-resscn 9339  ax-1cn 9340  ax-icn 9341  ax-addcl 9342  ax-addrcl 9343  ax-mulcl 9344  ax-mulrcl 9345  ax-mulcom 9346  ax-addass 9347  ax-mulass 9348  ax-distr 9349  ax-i2m1 9350  ax-1ne0 9351  ax-1rid 9352  ax-rnegex 9353  ax-rrecex 9354  ax-cnre 9355  ax-pre-lttri 9356  ax-pre-lttrn 9357  ax-pre-ltadd 9358  ax-pre-mulgt0 9359  ax-pre-sup 9360
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-tru 1372  df-ex 1587  df-nf 1590  df-sb 1701  df-eu 2257  df-mo 2258  df-clab 2430  df-cleq 2436  df-clel 2439  df-nfc 2568  df-ne 2608  df-nel 2609  df-ral 2720  df-rex 2721  df-reu 2722  df-rmo 2723  df-rab 2724  df-v 2974  df-sbc 3187  df-csb 3289  df-dif 3331  df-un 3333  df-in 3335  df-ss 3342  df-pss 3344  df-nul 3638  df-if 3792  df-pw 3862  df-sn 3878  df-pr 3880  df-tp 3882  df-op 3884  df-uni 4092  df-iun 4173  df-br 4293  df-opab 4351  df-mpt 4352  df-tr 4386  df-eprel 4632  df-id 4636  df-po 4641  df-so 4642  df-fr 4679  df-we 4681  df-ord 4722  df-on 4723  df-lim 4724  df-suc 4725  df-xp 4846  df-rel 4847  df-cnv 4848  df-co 4849  df-dm 4850  df-rn 4851  df-res 4852  df-ima 4853  df-iota 5381  df-fun 5420  df-fn 5421  df-f 5422  df-f1 5423  df-fo 5424  df-f1o 5425  df-fv 5426  df-riota 6052  df-ov 6094  df-oprab 6095  df-mpt2 6096  df-om 6477  df-1st 6577  df-2nd 6578  df-recs 6832  df-rdg 6866  df-er 7101  df-en 7311  df-dom 7312  df-sdom 7313  df-sup 7691  df-pnf 9420  df-mnf 9421  df-xr 9422  df-ltxr 9423  df-le 9424  df-sub 9597  df-neg 9598  df-div 9994  df-nn 10323  df-2 10380  df-3 10381  df-n0 10580  df-z 10647  df-uz 10862  df-rp 10992  df-fz 11438  df-seq 11807  df-exp 11866  df-cj 12588  df-re 12589  df-im 12590  df-sqr 12724  df-abs 12725  df-dvds 13536
This theorem is referenced by:  divalg2  13609
  Copyright terms: Public domain W3C validator