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

Theorem bitsinv1 12633
Description: There is an explicit inverse to the bits function for nonnegative integers (which can be extended to negative integers using bitscmp 12629), part 1. (Contributed by Mario Carneiro, 7-Sep-2016.)
Assertion
Ref Expression
bitsinv1  |-  ( N  e.  NN0  ->  sum_ n  e.  (bits `  N )
( 2 ^ n
)  =  N )
Distinct variable group:    n, N

Proof of Theorem bitsinv1
Dummy variables  k  x are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 id 19 . . 3  |-  ( N  e.  NN0  ->  N  e. 
NN0 )
2 oveq2 5866 . . . . . . . . . . 11  |-  ( x  =  0  ->  (
0..^ x )  =  ( 0..^ 0 ) )
3 fzo0 10893 . . . . . . . . . . 11  |-  ( 0..^ 0 )  =  (/)
42, 3syl6eq 2331 . . . . . . . . . 10  |-  ( x  =  0  ->  (
0..^ x )  =  (/) )
54ineq2d 3370 . . . . . . . . 9  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (/) ) )
6 in0 3480 . . . . . . . . 9  |-  ( (bits `  N )  i^i  (/) )  =  (/)
75, 6syl6eq 2331 . . . . . . . 8  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  (/) )
87sumeq1d 12174 . . . . . . 7  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
9 sum0 12194 . . . . . . 7  |-  sum_ n  e.  (/)  ( 2 ^ n )  =  0
108, 9syl6eq 2331 . . . . . 6  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  0 )
11 oveq2 5866 . . . . . . . 8  |-  ( x  =  0  ->  (
2 ^ x )  =  ( 2 ^ 0 ) )
12 2cn 9816 . . . . . . . . 9  |-  2  e.  CC
13 exp0 11108 . . . . . . . . 9  |-  ( 2  e.  CC  ->  (
2 ^ 0 )  =  1 )
1412, 13ax-mp 8 . . . . . . . 8  |-  ( 2 ^ 0 )  =  1
1511, 14syl6eq 2331 . . . . . . 7  |-  ( x  =  0  ->  (
2 ^ x )  =  1 )
1615oveq2d 5874 . . . . . 6  |-  ( x  =  0  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  1
) )
1710, 16eqeq12d 2297 . . . . 5  |-  ( x  =  0  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  0  =  ( N  mod  1
) ) )
1817imbi2d 307 . . . 4  |-  ( x  =  0  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  0  =  ( N  mod  1 ) ) ) )
19 oveq2 5866 . . . . . . . 8  |-  ( x  =  k  ->  (
0..^ x )  =  ( 0..^ k ) )
2019ineq2d 3370 . . . . . . 7  |-  ( x  =  k  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ k ) ) )
2120sumeq1d 12174 . . . . . 6  |-  ( x  =  k  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n ) )
22 oveq2 5866 . . . . . . 7  |-  ( x  =  k  ->  (
2 ^ x )  =  ( 2 ^ k ) )
2322oveq2d 5874 . . . . . 6  |-  ( x  =  k  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ k ) ) )
2421, 23eqeq12d 2297 . . . . 5  |-  ( x  =  k  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ k ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ k
) ) ) )
2524imbi2d 307 . . . 4  |-  ( x  =  k  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ k ) ) ) ) )
26 oveq2 5866 . . . . . . . 8  |-  ( x  =  ( k  +  1 )  ->  (
0..^ x )  =  ( 0..^ ( k  +  1 ) ) )
2726ineq2d 3370 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) )
2827sumeq1d 12174 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n ) )
29 oveq2 5866 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
2 ^ x )  =  ( 2 ^ ( k  +  1 ) ) )
3029oveq2d 5874 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ ( k  +  1 ) ) ) )
3128, 30eqeq12d 2297 . . . . 5  |-  ( x  =  ( k  +  1 )  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ (
k  +  1 ) ) ) ) )
3231imbi2d 307 . . . 4  |-  ( x  =  ( k  +  1 )  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) ) )
33 oveq2 5866 . . . . . . . 8  |-  ( x  =  N  ->  (
0..^ x )  =  ( 0..^ N ) )
3433ineq2d 3370 . . . . . . 7  |-  ( x  =  N  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ N ) ) )
3534sumeq1d 12174 . . . . . 6  |-  ( x  =  N  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ N ) ) ( 2 ^ n ) )
36 oveq2 5866 . . . . . . 7  |-  ( x  =  N  ->  (
2 ^ x )  =  ( 2 ^ N ) )
3736oveq2d 5874 . . . . . 6  |-  ( x  =  N  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ N ) ) )
3835, 37eqeq12d 2297 . . . . 5  |-  ( x  =  N  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) ) )
3938imbi2d 307 . . . 4  |-  ( x  =  N  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N ) ) ) ) )
40 nn0z 10046 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ZZ )
41 zmod10 10987 . . . . . 6  |-  ( N  e.  ZZ  ->  ( N  mod  1 )  =  0 )
4240, 41syl 15 . . . . 5  |-  ( N  e.  NN0  ->  ( N  mod  1 )  =  0 )
4342eqcomd 2288 . . . 4  |-  ( N  e.  NN0  ->  0  =  ( N  mod  1
) )
44 oveq1 5865 . . . . . . 7  |-  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ k ) )  -> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  +  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  sum_ n  e.  ( (bits `  N )  i^i  { k } ) ( 2 ^ n
) ) )
45 inindi 3386 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  i^i  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  i^i  ( (bits `  N
)  i^i  { k } ) )
46 fzonel 10887 . . . . . . . . . . . . . 14  |-  -.  k  e.  ( 0..^ k )
4746a1i 10 . . . . . . . . . . . . 13  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  -.  k  e.  (
0..^ k ) )
48 disjsn 3693 . . . . . . . . . . . . 13  |-  ( ( ( 0..^ k )  i^i  { k } )  =  (/)  <->  -.  k  e.  ( 0..^ k ) )
4947, 48sylibr 203 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( 0..^ k )  i^i  { k } )  =  (/) )
5049ineq2d 3370 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  ( (bits `  N )  i^i  (/) ) )
5150, 6syl6eq 2331 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  (/) )
5245, 51syl5eqr 2329 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( (bits `  N )  i^i  (
0..^ k ) )  i^i  ( (bits `  N )  i^i  {
k } ) )  =  (/) )
53 simpr 447 . . . . . . . . . . . . 13  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  NN0 )
54 nn0uz 10262 . . . . . . . . . . . . 13  |-  NN0  =  ( ZZ>= `  0 )
5553, 54syl6eleq 2373 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  ( ZZ>= ` 
0 ) )
56 fzosplitsn 10920 . . . . . . . . . . . 12  |-  ( k  e.  ( ZZ>= `  0
)  ->  ( 0..^ ( k  +  1 ) )  =  ( ( 0..^ k )  u.  { k } ) )
5755, 56syl 15 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( 0..^ ( k  +  1 ) )  =  ( ( 0..^ k )  u.  {
k } ) )
5857ineq2d 3370 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( (bits `  N
)  i^i  ( (
0..^ k )  u. 
{ k } ) ) )
59 indi 3415 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  u.  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  u.  ( (bits `  N
)  i^i  { k } ) )
6058, 59syl6eq 2331 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( ( (bits `  N )  i^i  (
0..^ k ) )  u.  ( (bits `  N )  i^i  {
k } ) ) )
61 fzofi 11036 . . . . . . . . . . 11  |-  ( 0..^ ( k  +  1 ) )  e.  Fin
62 inss2 3390 . . . . . . . . . . 11  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) 
C_  ( 0..^ ( k  +  1 ) )
63 ssfi 7083 . . . . . . . . . . 11  |-  ( ( ( 0..^ ( k  +  1 ) )  e.  Fin  /\  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) )  C_  ( 0..^ ( k  +  1 ) ) )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  e. 
Fin )
6461, 62, 63mp2an 653 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) )  e.  Fin
6564a1i 10 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  e. 
Fin )
66 2nn 9877 . . . . . . . . . . . 12  |-  2  e.  NN
6766a1i 10 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  2  e.  NN )
68 simpr 447 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) ) )
6962, 68sseldi 3178 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( 0..^ ( k  +  1 ) ) )
70 elfzouz 10879 . . . . . . . . . . . . 13  |-  ( n  e.  ( 0..^ ( k  +  1 ) )  ->  n  e.  ( ZZ>= `  0 )
)
7169, 70syl 15 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( ZZ>= `  0 )
)
7271, 54syl6eleqr 2374 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  NN0 )
7367, 72nnexpcld 11266 . . . . . . . . . 10  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  NN )
7473nncnd 9762 . . . . . . . . 9  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  CC )
7552, 60, 65, 74fsumsplit 12212 . . . . . . . 8  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  sum_ n  e.  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) ( 2 ^ n
)  =  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  +  sum_ n  e.  ( (bits `  N
)  i^i  { k } ) ( 2 ^ n ) ) )
76 bitsinv1lem 12632 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
7740, 76sylan 457 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
78 eqeq2 2292 . . . . . . . . . . 11  |-  ( ( 2 ^ k )  =  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 )  ->  ( sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  ( 2 ^ k )  <->  sum_ n  e.  ( (bits `  N
)  i^i  { k } ) ( 2 ^ n )  =  if ( k  e.  (bits `  N ) ,  ( 2 ^ k ) ,  0 ) ) )
79 eqeq2 2292 . . . . . . . . . . 11  |-  ( 0  =  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 )  ->  ( sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  0  <->  sum_ n  e.  ( (bits `  N
)  i^i  { k } ) ( 2 ^ n )  =  if ( k  e.  (bits `  N ) ,  ( 2 ^ k ) ,  0 ) ) )
80 simpr 447 . . . . . . . . . . . . . . 15  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
k  e.  (bits `  N ) )
8180snssd 3760 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  { k }  C_  (bits `  N ) )
82 dfss1 3373 . . . . . . . . . . . . . 14  |-  ( { k }  C_  (bits `  N )  <->  ( (bits `  N )  i^i  {
k } )  =  { k } )
8381, 82sylib 188 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( (bits `  N
)  i^i  { k } )  =  {
k } )
8483sumeq1d 12174 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  sum_ n  e.  {
k }  ( 2 ^ n ) )
85 simplr 731 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
k  e.  NN0 )
8666a1i 10 . . . . . . . . . . . . . . 15  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
2  e.  NN )
8786, 85nnexpcld 11266 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  NN )
8887nncnd 9762 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  CC )
89 oveq2 5866 . . . . . . . . . . . . . 14  |-  ( n  =  k  ->  (
2 ^ n )  =  ( 2 ^ k ) )
9089sumsn 12213 . . . . . . . . . . . . 13  |-  ( ( k  e.  NN0  /\  ( 2 ^ k
)  e.  CC )  ->  sum_ n  e.  {
k }  ( 2 ^ n )  =  ( 2 ^ k
) )
9185, 88, 90syl2anc 642 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  { k }  ( 2 ^ n )  =  ( 2 ^ k ) )
9284, 91eqtrd 2315 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  ( 2 ^ k ) )
93 simpr 447 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  -.  k  e.  (bits `  N ) )
94 disjsn 3693 . . . . . . . . . . . . . 14  |-  ( ( (bits `  N )  i^i  { k } )  =  (/)  <->  -.  k  e.  (bits `  N ) )
9593, 94sylibr 203 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  -> 
( (bits `  N
)  i^i  { k } )  =  (/) )
9695sumeq1d 12174 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
9796, 9syl6eq 2331 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  0 )
9878, 79, 92, 97ifbothda 3595 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) )
9998oveq2d 5874 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( N  mod  ( 2 ^ k
) )  +  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
10077, 99eqtr4d 2318 . . . . . . . 8  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  sum_ n  e.  ( (bits `  N )  i^i  { k } ) ( 2 ^ n
) ) )
10175, 100eqeq12d 2297 . . . . . . 7  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) )  <-> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  +  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  sum_ n  e.  ( (bits `  N )  i^i  { k } ) ( 2 ^ n
) ) ) )
10244, 101syl5ibr 212 . . . . . 6  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ k ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) )
103102expcom 424 . . . . 5  |-  ( k  e.  NN0  ->  ( N  e.  NN0  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ k ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) ) )
104103a2d 23 . . . 4  |-  ( k  e.  NN0  ->  ( ( N  e.  NN0  ->  sum_
n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ k ) ) )  ->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) ) )
10518, 25, 32, 39, 43, 104nn0ind 10108 . . 3  |-  ( N  e.  NN0  ->  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) ) )
1061, 105mpd 14 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) )
1071, 54syl6eleq 2373 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ( ZZ>= `  0 )
)
10866a1i 10 . . . . . . . 8  |-  ( N  e.  NN0  ->  2  e.  NN )
109108, 1nnexpcld 11266 . . . . . . 7  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  NN )
110109nnzd 10116 . . . . . 6  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  ZZ )
111 2z 10054 . . . . . . . 8  |-  2  e.  ZZ
112 uzid 10242 . . . . . . . 8  |-  ( 2  e.  ZZ  ->  2  e.  ( ZZ>= `  2 )
)
113111, 112ax-mp 8 . . . . . . 7  |-  2  e.  ( ZZ>= `  2 )
114 bernneq3 11229 . . . . . . 7  |-  ( ( 2  e.  ( ZZ>= ` 
2 )  /\  N  e.  NN0 )  ->  N  <  ( 2 ^ N
) )
115113, 114mpan 651 . . . . . 6  |-  ( N  e.  NN0  ->  N  < 
( 2 ^ N
) )
116 elfzo2 10878 . . . . . 6  |-  ( N  e.  ( 0..^ ( 2 ^ N ) )  <->  ( N  e.  ( ZZ>= `  0 )  /\  ( 2 ^ N
)  e.  ZZ  /\  N  <  ( 2 ^ N ) ) )
117107, 110, 115, 116syl3anbrc 1136 . . . . 5  |-  ( N  e.  NN0  ->  N  e.  ( 0..^ ( 2 ^ N ) ) )
118 bitsfzo 12626 . . . . . 6  |-  ( ( N  e.  ZZ  /\  N  e.  NN0 )  -> 
( N  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  N
)  C_  ( 0..^ N ) ) )
11940, 1, 118syl2anc 642 . . . . 5  |-  ( N  e.  NN0  ->  ( N  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  N )  C_  ( 0..^ N ) ) )
120117, 119mpbid 201 . . . 4  |-  ( N  e.  NN0  ->  (bits `  N )  C_  (
0..^ N ) )
121 df-ss 3166 . . . 4  |-  ( (bits `  N )  C_  (
0..^ N )  <->  ( (bits `  N )  i^i  (
0..^ N ) )  =  (bits `  N
) )
122120, 121sylib 188 . . 3  |-  ( N  e.  NN0  ->  ( (bits `  N )  i^i  (
0..^ N ) )  =  (bits `  N
) )
123122sumeq1d 12174 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  sum_ n  e.  (bits `  N ) ( 2 ^ n ) )
124 nn0re 9974 . . 3  |-  ( N  e.  NN0  ->  N  e.  RR )
125 2rp 10359 . . . . 5  |-  2  e.  RR+
126125a1i 10 . . . 4  |-  ( N  e.  NN0  ->  2  e.  RR+ )
127126, 40rpexpcld 11268 . . 3  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  RR+ )
128 nn0ge0 9991 . . 3  |-  ( N  e.  NN0  ->  0  <_  N )
129 modid 10993 . . 3  |-  ( ( ( N  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  /\  ( 0  <_  N  /\  N  <  ( 2 ^ N ) ) )  ->  ( N  mod  ( 2 ^ N
) )  =  N )
130124, 127, 128, 115, 129syl22anc 1183 . 2  |-  ( N  e.  NN0  ->  ( N  mod  ( 2 ^ N ) )  =  N )
131106, 123, 1303eqtr3d 2323 1  |-  ( N  e.  NN0  ->  sum_ n  e.  (bits `  N )
( 2 ^ n
)  =  N )
Colors of variables: wff set class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 176    /\ wa 358    = wceq 1623    e. wcel 1684    u. cun 3150    i^i cin 3151    C_ wss 3152   (/)c0 3455   ifcif 3565   {csn 3640   class class class wbr 4023   ` cfv 5255  (class class class)co 5858   Fincfn 6863   CCcc 8735   RRcr 8736   0cc0 8737   1c1 8738    + caddc 8740    < clt 8867    <_ cle 8868   NNcn 9746   2c2 9795   NN0cn0 9965   ZZcz 10024   ZZ>=cuz 10230   RR+crp 10354  ..^cfzo 10870    mod cmo 10973   ^cexp 11104   sum_csu 12158  bitscbits 12610
This theorem is referenced by:  bitsinv2  12634  bitsf1ocnv  12635
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1533  ax-5 1544  ax-17 1603  ax-9 1635  ax-8 1643  ax-13 1686  ax-14 1688  ax-6 1703  ax-7 1708  ax-11 1715  ax-12 1866  ax-ext 2264  ax-rep 4131  ax-sep 4141  ax-nul 4149  ax-pow 4188  ax-pr 4214  ax-un 4512  ax-inf2 7342  ax-cnex 8793  ax-resscn 8794  ax-1cn 8795  ax-icn 8796  ax-addcl 8797  ax-addrcl 8798  ax-mulcl 8799  ax-mulrcl 8800  ax-mulcom 8801  ax-addass 8802  ax-mulass 8803  ax-distr 8804  ax-i2m1 8805  ax-1ne0 8806  ax-1rid 8807  ax-rnegex 8808  ax-rrecex 8809  ax-cnre 8810  ax-pre-lttri 8811  ax-pre-lttrn 8812  ax-pre-ltadd 8813  ax-pre-mulgt0 8814  ax-pre-sup 8815
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 935  df-3an 936  df-tru 1310  df-ex 1529  df-nf 1532  df-sb 1630  df-eu 2147  df-mo 2148  df-clab 2270  df-cleq 2276  df-clel 2279  df-nfc 2408  df-ne 2448  df-nel 2449  df-ral 2548  df-rex 2549  df-reu 2550  df-rmo 2551  df-rab 2552  df-v 2790  df-sbc 2992  df-csb 3082  df-dif 3155  df-un 3157  df-in 3159  df-ss 3166  df-pss 3168  df-nul 3456  df-if 3566  df-pw 3627  df-sn 3646  df-pr 3647  df-tp 3648  df-op 3649  df-uni 3828  df-int 3863  df-iun 3907  df-br 4024  df-opab 4078  df-mpt 4079  df-tr 4114  df-eprel 4305  df-id 4309  df-po 4314  df-so 4315  df-fr 4352  df-se 4353  df-we 4354  df-ord 4395  df-on 4396  df-lim 4397  df-suc 4398  df-om 4657  df-xp 4695  df-rel 4696  df-cnv 4697  df-co 4698  df-dm 4699  df-rn 4700  df-res 4701  df-ima 4702  df-iota 5219  df-fun 5257  df-fn 5258  df-f 5259  df-f1 5260  df-fo 5261  df-f1o 5262  df-fv 5263  df-isom 5264  df-ov 5861  df-oprab 5862  df-mpt2 5863  df-1st 6122  df-2nd 6123  df-riota 6304  df-recs 6388  df-rdg 6423  df-1o 6479  df-oadd 6483  df-er 6660  df-en 6864  df-dom 6865  df-sdom 6866  df-fin 6867  df-sup 7194  df-oi 7225  df-card 7572  df-pnf 8869  df-mnf 8870  df-xr 8871  df-ltxr 8872  df-le 8873  df-sub 9039  df-neg 9040  df-div 9424  df-nn 9747  df-2 9804  df-3 9805  df-n0 9966  df-z 10025  df-uz 10231  df-rp 10355  df-fz 10783  df-fzo 10871  df-fl 10925  df-mod 10974  df-seq 11047  df-exp 11105  df-hash 11338  df-cj 11584  df-re 11585  df-im 11586  df-sqr 11720  df-abs 11721  df-clim 11962  df-sum 12159  df-dvds 12532  df-bits 12613
  Copyright terms: Public domain W3C validator