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

Theorem modifeq2int 12031
Description: If a nonnegative integer is less than the double of a positive integer, the nonnegative integer modulo the positive integer equals the nonnegative integer or the nonnegative integer minus the positive integer. (Contributed by Alexander van der Vekens, 21-May-2018.)
Assertion
Ref Expression
modifeq2int  |-  ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B
) )  ->  ( A  mod  B )  =  if ( A  < 
B ,  A , 
( A  -  B
) ) )

Proof of Theorem modifeq2int
StepHypRef Expression
1 nn0re 10800 . . . . . . . 8  |-  ( A  e.  NN0  ->  A  e.  RR )
2 nnrp 11230 . . . . . . . 8  |-  ( B  e.  NN  ->  B  e.  RR+ )
31, 2anim12i 564 . . . . . . 7  |-  ( ( A  e.  NN0  /\  B  e.  NN )  ->  ( A  e.  RR  /\  B  e.  RR+ )
)
433adant3 1014 . . . . . 6  |-  ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B
) )  ->  ( A  e.  RR  /\  B  e.  RR+ ) )
54adantl 464 . . . . 5  |-  ( ( A  <  B  /\  ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) ) )  ->  ( A  e.  RR  /\  B  e.  RR+ ) )
6 nn0ge0 10817 . . . . . . . 8  |-  ( A  e.  NN0  ->  0  <_  A )
763ad2ant1 1015 . . . . . . 7  |-  ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B
) )  ->  0  <_  A )
87anim1i 566 . . . . . 6  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  A  <  B )  -> 
( 0  <_  A  /\  A  <  B ) )
98ancoms 451 . . . . 5  |-  ( ( A  <  B  /\  ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) ) )  ->  ( 0  <_  A  /\  A  <  B
) )
10 modid 12002 . . . . 5  |-  ( ( ( A  e.  RR  /\  B  e.  RR+ )  /\  ( 0  <_  A  /\  A  <  B ) )  ->  ( A  mod  B )  =  A )
115, 9, 10syl2anc 659 . . . 4  |-  ( ( A  <  B  /\  ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) ) )  ->  ( A  mod  B )  =  A )
12 iftrue 3935 . . . . . 6  |-  ( A  <  B  ->  if ( A  <  B ,  A ,  ( A  -  B ) )  =  A )
1312eqcomd 2462 . . . . 5  |-  ( A  <  B  ->  A  =  if ( A  < 
B ,  A , 
( A  -  B
) ) )
1413adantr 463 . . . 4  |-  ( ( A  <  B  /\  ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) ) )  ->  A  =  if ( A  <  B ,  A ,  ( A  -  B ) ) )
1511, 14eqtrd 2495 . . 3  |-  ( ( A  <  B  /\  ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) ) )  ->  ( A  mod  B )  =  if ( A  <  B ,  A ,  ( A  -  B ) ) )
1615ex 432 . 2  |-  ( A  <  B  ->  (
( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  -> 
( A  mod  B
)  =  if ( A  <  B ,  A ,  ( A  -  B ) ) ) )
174adantr 463 . . . . 5  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  ( A  e.  RR  /\  B  e.  RR+ ) )
18 nnre 10538 . . . . . . . 8  |-  ( B  e.  NN  ->  B  e.  RR )
19 lenlt 9652 . . . . . . . 8  |-  ( ( B  e.  RR  /\  A  e.  RR )  ->  ( B  <_  A  <->  -.  A  <  B ) )
2018, 1, 19syl2anr 476 . . . . . . 7  |-  ( ( A  e.  NN0  /\  B  e.  NN )  ->  ( B  <_  A  <->  -.  A  <  B ) )
21203adant3 1014 . . . . . 6  |-  ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B
) )  ->  ( B  <_  A  <->  -.  A  <  B ) )
2221biimpar 483 . . . . 5  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  B  <_  A
)
23 simpl3 999 . . . . 5  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  A  <  (
2  x.  B ) )
24 2submod 12030 . . . . 5  |-  ( ( ( A  e.  RR  /\  B  e.  RR+ )  /\  ( B  <_  A  /\  A  <  ( 2  x.  B ) ) )  ->  ( A  mod  B )  =  ( A  -  B ) )
2517, 22, 23, 24syl12anc 1224 . . . 4  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  ( A  mod  B )  =  ( A  -  B ) )
26 iffalse 3938 . . . . . 6  |-  ( -.  A  <  B  ->  if ( A  <  B ,  A ,  ( A  -  B ) )  =  ( A  -  B ) )
2726adantl 464 . . . . 5  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  if ( A  <  B ,  A ,  ( A  -  B ) )  =  ( A  -  B
) )
2827eqcomd 2462 . . . 4  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  ( A  -  B )  =  if ( A  <  B ,  A ,  ( A  -  B ) ) )
2925, 28eqtrd 2495 . . 3  |-  ( ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B ) )  /\  -.  A  <  B )  ->  ( A  mod  B )  =  if ( A  <  B ,  A ,  ( A  -  B ) ) )
3029expcom 433 . 2  |-  ( -.  A  <  B  -> 
( ( A  e. 
NN0  /\  B  e.  NN  /\  A  <  (
2  x.  B ) )  ->  ( A  mod  B )  =  if ( A  <  B ,  A ,  ( A  -  B ) ) ) )
3116, 30pm2.61i 164 1  |-  ( ( A  e.  NN0  /\  B  e.  NN  /\  A  <  ( 2  x.  B
) )  ->  ( A  mod  B )  =  if ( A  < 
B ,  A , 
( A  -  B
) ) )
Colors of variables: wff setvar class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 184    /\ wa 367    /\ w3a 971    = wceq 1398    e. wcel 1823   ifcif 3929   class class class wbr 4439  (class class class)co 6270   RRcr 9480   0cc0 9481    x. cmul 9486    < clt 9617    <_ cle 9618    - cmin 9796   NNcn 10531   2c2 10581   NN0cn0 10791   RR+crp 11221    mod cmo 11978
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1623  ax-4 1636  ax-5 1709  ax-6 1752  ax-7 1795  ax-8 1825  ax-9 1827  ax-10 1842  ax-11 1847  ax-12 1859  ax-13 2004  ax-ext 2432  ax-sep 4560  ax-nul 4568  ax-pow 4615  ax-pr 4676  ax-un 6565  ax-cnex 9537  ax-resscn 9538  ax-1cn 9539  ax-icn 9540  ax-addcl 9541  ax-addrcl 9542  ax-mulcl 9543  ax-mulrcl 9544  ax-mulcom 9545  ax-addass 9546  ax-mulass 9547  ax-distr 9548  ax-i2m1 9549  ax-1ne0 9550  ax-1rid 9551  ax-rnegex 9552  ax-rrecex 9553  ax-cnre 9554  ax-pre-lttri 9555  ax-pre-lttrn 9556  ax-pre-ltadd 9557  ax-pre-mulgt0 9558  ax-pre-sup 9559
This theorem depends on definitions:  df-bi 185  df-or 368  df-an 369  df-3or 972  df-3an 973  df-tru 1401  df-ex 1618  df-nf 1622  df-sb 1745  df-eu 2288  df-mo 2289  df-clab 2440  df-cleq 2446  df-clel 2449  df-nfc 2604  df-ne 2651  df-nel 2652  df-ral 2809  df-rex 2810  df-reu 2811  df-rmo 2812  df-rab 2813  df-v 3108  df-sbc 3325  df-csb 3421  df-dif 3464  df-un 3466  df-in 3468  df-ss 3475  df-pss 3477  df-nul 3784  df-if 3930  df-pw 4001  df-sn 4017  df-pr 4019  df-tp 4021  df-op 4023  df-uni 4236  df-iun 4317  df-br 4440  df-opab 4498  df-mpt 4499  df-tr 4533  df-eprel 4780  df-id 4784  df-po 4789  df-so 4790  df-fr 4827  df-we 4829  df-ord 4870  df-on 4871  df-lim 4872  df-suc 4873  df-xp 4994  df-rel 4995  df-cnv 4996  df-co 4997  df-dm 4998  df-rn 4999  df-res 5000  df-ima 5001  df-iota 5534  df-fun 5572  df-fn 5573  df-f 5574  df-f1 5575  df-fo 5576  df-f1o 5577  df-fv 5578  df-riota 6232  df-ov 6273  df-oprab 6274  df-mpt2 6275  df-om 6674  df-recs 7034  df-rdg 7068  df-er 7303  df-en 7510  df-dom 7511  df-sdom 7512  df-sup 7893  df-pnf 9619  df-mnf 9620  df-xr 9621  df-ltxr 9622  df-le 9623  df-sub 9798  df-neg 9799  df-div 10203  df-nn 10532  df-2 10590  df-n0 10792  df-z 10861  df-uz 11083  df-rp 11222  df-fl 11910  df-mod 11979
This theorem is referenced by: (None)
  Copyright terms: Public domain W3C validator