Metamath Proof Explorer


Theorem nnpw2pmod

Description: Every positive integer can be represented as the sum of a power of 2 and a "remainder" smaller than the power. (Contributed by AV, 31-May-2020)

Ref Expression
Assertion nnpw2pmod N N = 2 # b N 1 + N mod 2 # b N 1

Proof

Step Hyp Ref Expression
1 nnre N N
2 2nn 2
3 2 a1i N 2
4 blennnelnn N # b N
5 nnm1nn0 # b N # b N 1 0
6 4 5 syl N # b N 1 0
7 3 6 nnexpcld N 2 # b N 1
8 7 nnrpd N 2 # b N 1 +
9 modeqmodmin N 2 # b N 1 + N mod 2 # b N 1 = N 2 # b N 1 mod 2 # b N 1
10 1 8 9 syl2anc N N mod 2 # b N 1 = N 2 # b N 1 mod 2 # b N 1
11 7 nnred N 2 # b N 1
12 1 11 resubcld N N 2 # b N 1
13 nnpw2blen N 2 # b N 1 N N < 2 # b N
14 1 11 subge0d N 0 N 2 # b N 1 2 # b N 1 N
15 1 11 11 ltsubadd2d N N 2 # b N 1 < 2 # b N 1 N < 2 # b N 1 + 2 # b N 1
16 2cn 2
17 exp1 2 2 1 = 2
18 17 eqcomd 2 2 = 2 1
19 16 18 mp1i N 2 = 2 1
20 19 oveq1d N 2 2 # b N 1 = 2 1 2 # b N 1
21 7 nncnd N 2 # b N 1
22 21 2timesd N 2 2 # b N 1 = 2 # b N 1 + 2 # b N 1
23 16 a1i N 2
24 1nn0 1 0
25 24 a1i N 1 0
26 23 6 25 expaddd N 2 1 + # b N - 1 = 2 1 2 # b N 1
27 1cnd N 1
28 4 nncnd N # b N
29 27 28 pncan3d N 1 + # b N - 1 = # b N
30 29 oveq2d N 2 1 + # b N - 1 = 2 # b N
31 26 30 eqtr3d N 2 1 2 # b N 1 = 2 # b N
32 20 22 31 3eqtr3d N 2 # b N 1 + 2 # b N 1 = 2 # b N
33 32 breq2d N N < 2 # b N 1 + 2 # b N 1 N < 2 # b N
34 15 33 bitrd N N 2 # b N 1 < 2 # b N 1 N < 2 # b N
35 14 34 anbi12d N 0 N 2 # b N 1 N 2 # b N 1 < 2 # b N 1 2 # b N 1 N N < 2 # b N
36 13 35 mpbird N 0 N 2 # b N 1 N 2 # b N 1 < 2 # b N 1
37 modid N 2 # b N 1 2 # b N 1 + 0 N 2 # b N 1 N 2 # b N 1 < 2 # b N 1 N 2 # b N 1 mod 2 # b N 1 = N 2 # b N 1
38 12 8 36 37 syl21anc N N 2 # b N 1 mod 2 # b N 1 = N 2 # b N 1
39 10 38 eqtr2d N N 2 # b N 1 = N mod 2 # b N 1
40 nncn N N
41 nnz N N
42 41 7 zmodcld N N mod 2 # b N 1 0
43 42 nn0cnd N N mod 2 # b N 1
44 40 21 43 subaddd N N 2 # b N 1 = N mod 2 # b N 1 2 # b N 1 + N mod 2 # b N 1 = N
45 39 44 mpbid N 2 # b N 1 + N mod 2 # b N 1 = N
46 45 eqcomd N N = 2 # b N 1 + N mod 2 # b N 1