Metamath Proof Explorer


Theorem nnpw2p

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 nnpw2p Ni0r0..^2iN=2i+r

Proof

Step Hyp Ref Expression
1 blennnelnn N#b N
2 nnm1nn0 #b N #b N10
3 1 2 syl N#b N 1 0
4 oveq2 i=#b N 1 2i=2#b N1
5 4 oveq2d i=#b N 1 0..^2i=0..^2#b N1
6 4 oveq1d i=#b N 1 2i+r=2#b N1+r
7 6 eqeq2d i=#b N 1 N=2i+rN=2#b N1+r
8 5 7 rexeqbidv i=#b N 1 r0..^2iN=2i+rr0..^2#b N1N=2#b N1+r
9 8 adantl Ni=#b N 1 r0..^2iN=2i+rr0..^2#b N1N=2#b N1+r
10 nnz NN
11 2nn 2
12 11 a1i N2
13 12 3 nnexpcld N2#b N 1
14 zmodfzo N2#b N 1 Nmod2#b N10..^2#b N1
15 10 13 14 syl2anc NNmod2#b N 1 0..^2#b N1
16 oveq2 r=Nmod2#b N 1 2#b N1+r=2#b N1+Nmod2#b N1
17 16 eqeq2d r=Nmod2#b N 1 N=2#b N1+rN=2#b N1+Nmod2#b N1
18 17 adantl Nr=Nmod2#b N 1 N=2#b N1+rN=2#b N1+Nmod2#b N1
19 nnpw2pmod NN=2#b N 1 + Nmod2#b N1
20 15 18 19 rspcedvd Nr0..^2#b N 1 N=2#b N1+r
21 3 9 20 rspcedvd Ni0r0..^2iN=2i+r