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

Theorem bitsinv1 12649
Description: There is an explicit inverse to the bits function for nonnegative integers (which can be extended to negative integers using bitscmp 12645), 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 5882 . . . . . . . . . . 11  |-  ( x  =  0  ->  (
0..^ x )  =  ( 0..^ 0 ) )
3 fzo0 10909 . . . . . . . . . . 11  |-  ( 0..^ 0 )  =  (/)
42, 3syl6eq 2344 . . . . . . . . . 10  |-  ( x  =  0  ->  (
0..^ x )  =  (/) )
54ineq2d 3383 . . . . . . . . 9  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (/) ) )
6 in0 3493 . . . . . . . . 9  |-  ( (bits `  N )  i^i  (/) )  =  (/)
75, 6syl6eq 2344 . . . . . . . 8  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  (/) )
87sumeq1d 12190 . . . . . . 7  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
9 sum0 12210 . . . . . . 7  |-  sum_ n  e.  (/)  ( 2 ^ n )  =  0
108, 9syl6eq 2344 . . . . . 6  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  0 )
11 oveq2 5882 . . . . . . . 8  |-  ( x  =  0  ->  (
2 ^ x )  =  ( 2 ^ 0 ) )
12 2cn 9832 . . . . . . . . 9  |-  2  e.  CC
13 exp0 11124 . . . . . . . . 9  |-  ( 2  e.  CC  ->  (
2 ^ 0 )  =  1 )
1412, 13ax-mp 8 . . . . . . . 8  |-  ( 2 ^ 0 )  =  1
1511, 14syl6eq 2344 . . . . . . 7  |-  ( x  =  0  ->  (
2 ^ x )  =  1 )
1615oveq2d 5890 . . . . . 6  |-  ( x  =  0  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  1
) )
1710, 16eqeq12d 2310 . . . . 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 5882 . . . . . . . 8  |-  ( x  =  k  ->  (
0..^ x )  =  ( 0..^ k ) )
2019ineq2d 3383 . . . . . . 7  |-  ( x  =  k  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ k ) ) )
2120sumeq1d 12190 . . . . . 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 5882 . . . . . . 7  |-  ( x  =  k  ->  (
2 ^ x )  =  ( 2 ^ k ) )
2322oveq2d 5890 . . . . . 6  |-  ( x  =  k  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ k ) ) )
2421, 23eqeq12d 2310 . . . . 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 5882 . . . . . . . 8  |-  ( x  =  ( k  +  1 )  ->  (
0..^ x )  =  ( 0..^ ( k  +  1 ) ) )
2726ineq2d 3383 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) )
2827sumeq1d 12190 . . . . . 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 5882 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
2 ^ x )  =  ( 2 ^ ( k  +  1 ) ) )
3029oveq2d 5890 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ ( k  +  1 ) ) ) )
3128, 30eqeq12d 2310 . . . . 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 5882 . . . . . . . 8  |-  ( x  =  N  ->  (
0..^ x )  =  ( 0..^ N ) )
3433ineq2d 3383 . . . . . . 7  |-  ( x  =  N  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ N ) ) )
3534sumeq1d 12190 . . . . . 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 5882 . . . . . . 7  |-  ( x  =  N  ->  (
2 ^ x )  =  ( 2 ^ N ) )
3736oveq2d 5890 . . . . . 6  |-  ( x  =  N  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ N ) ) )
3835, 37eqeq12d 2310 . . . . 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 10062 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ZZ )
41 zmod10 11003 . . . . . 6  |-  ( N  e.  ZZ  ->  ( N  mod  1 )  =  0 )
4240, 41syl 15 . . . . 5  |-  ( N  e.  NN0  ->  ( N  mod  1 )  =  0 )
4342eqcomd 2301 . . . 4  |-  ( N  e.  NN0  ->  0  =  ( N  mod  1
) )
44 oveq1 5881 . . . . . . 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 3399 . . . . . . . . . 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 10903 . . . . . . . . . . . . . 14  |-  -.  k  e.  ( 0..^ k )
4746a1i 10 . . . . . . . . . . . . 13  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  -.  k  e.  (
0..^ k ) )
48 disjsn 3706 . . . . . . . . . . . . 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 3383 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  ( (bits `  N )  i^i  (/) ) )
5150, 6syl6eq 2344 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  (/) )
5245, 51syl5eqr 2342 . . . . . . . . 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 10278 . . . . . . . . . . . . 13  |-  NN0  =  ( ZZ>= `  0 )
5553, 54syl6eleq 2386 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  ( ZZ>= ` 
0 ) )
56 fzosplitsn 10936 . . . . . . . . . . . 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 3383 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( (bits `  N
)  i^i  ( (
0..^ k )  u. 
{ k } ) ) )
59 indi 3428 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  u.  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  u.  ( (bits `  N
)  i^i  { k } ) )
6058, 59syl6eq 2344 . . . . . . . . 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 11052 . . . . . . . . . . 11  |-  ( 0..^ ( k  +  1 ) )  e.  Fin
62 inss2 3403 . . . . . . . . . . 11  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) 
C_  ( 0..^ ( k  +  1 ) )
63 ssfi 7099 . . . . . . . . . . 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 9893 . . . . . . . . . . . 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 3191 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( 0..^ ( k  +  1 ) ) )
70 elfzouz 10895 . . . . . . . . . . . . 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 2387 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  NN0 )
7367, 72nnexpcld 11282 . . . . . . . . . 10  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  NN )
7473nncnd 9778 . . . . . . . . 9  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  CC )
7552, 60, 65, 74fsumsplit 12228 . . . . . . . 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 12648 . . . . . . . . . 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 2305 . . . . . . . . . . 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 2305 . . . . . . . . . . 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 3776 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  { k }  C_  (bits `  N ) )
82 dfss1 3386 . . . . . . . . . . . . . 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 12190 . . . . . . . . . . . 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 11282 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  NN )
8887nncnd 9778 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  CC )
89 oveq2 5882 . . . . . . . . . . . . . 14  |-  ( n  =  k  ->  (
2 ^ n )  =  ( 2 ^ k ) )
9089sumsn 12229 . . . . . . . . . . . . 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 2328 . . . . . . . . . . 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 3706 . . . . . . . . . . . . . 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 12190 . . . . . . . . . . . 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 2344 . . . . . . . . . . 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 3608 . . . . . . . . . 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 5890 . . . . . . . . 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 2331 . . . . . . . 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 2310 . . . . . . 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 10124 . . 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 2386 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ( ZZ>= `  0 )
)
10866a1i 10 . . . . . . . 8  |-  ( N  e.  NN0  ->  2  e.  NN )
109108, 1nnexpcld 11282 . . . . . . 7  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  NN )
110109nnzd 10132 . . . . . 6  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  ZZ )
111 2z 10070 . . . . . . . 8  |-  2  e.  ZZ
112 uzid 10258 . . . . . . . 8  |-  ( 2  e.  ZZ  ->  2  e.  ( ZZ>= `  2 )
)
113111, 112ax-mp 8 . . . . . . 7  |-  2  e.  ( ZZ>= `  2 )
114 bernneq3 11245 . . . . . . 7  |-  ( ( 2  e.  ( ZZ>= ` 
2 )  /\  N  e.  NN0 )  ->  N  <  ( 2 ^ N
) )
115113, 114mpan 651 . . . . . 6  |-  ( N  e.  NN0  ->  N  < 
( 2 ^ N
) )
116 elfzo2 10894 . . . . . 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 12642 . . . . . 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 3179 . . . 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 12190 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  sum_ n  e.  (bits `  N ) ( 2 ^ n ) )
124 nn0re 9990 . . 3  |-  ( N  e.  NN0  ->  N  e.  RR )
125 2rp 10375 . . . . 5  |-  2  e.  RR+
126125a1i 10 . . . 4  |-  ( N  e.  NN0  ->  2  e.  RR+ )
127126, 40rpexpcld 11284 . . 3  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  RR+ )
128 nn0ge0 10007 . . 3  |-  ( N  e.  NN0  ->  0  <_  N )
129 modid 11009 . . 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 2336 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 1632    e. wcel 1696    u. cun 3163    i^i cin 3164    C_ wss 3165   (/)c0 3468   ifcif 3578   {csn 3653   class class class wbr 4039   ` cfv 5271  (class class class)co 5874   Fincfn 6879   CCcc 8751   RRcr 8752   0cc0 8753   1c1 8754    + caddc 8756    < clt 8883    <_ cle 8884   NNcn 9762   2c2 9811   NN0cn0 9981   ZZcz 10040   ZZ>=cuz 10246   RR+crp 10370  ..^cfzo 10886    mod cmo 10989   ^cexp 11120   sum_csu 12174  bitscbits 12626
This theorem is referenced by:  bitsinv2  12650  bitsf1ocnv  12651
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1536  ax-5 1547  ax-17 1606  ax-9 1644  ax-8 1661  ax-13 1698  ax-14 1700  ax-6 1715  ax-7 1720  ax-11 1727  ax-12 1878  ax-ext 2277  ax-rep 4147  ax-sep 4157  ax-nul 4165  ax-pow 4204  ax-pr 4230  ax-un 4528  ax-inf2 7358  ax-cnex 8809  ax-resscn 8810  ax-1cn 8811  ax-icn 8812  ax-addcl 8813  ax-addrcl 8814  ax-mulcl 8815  ax-mulrcl 8816  ax-mulcom 8817  ax-addass 8818  ax-mulass 8819  ax-distr 8820  ax-i2m1 8821  ax-1ne0 8822  ax-1rid 8823  ax-rnegex 8824  ax-rrecex 8825  ax-cnre 8826  ax-pre-lttri 8827  ax-pre-lttrn 8828  ax-pre-ltadd 8829  ax-pre-mulgt0 8830  ax-pre-sup 8831
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 1532  df-nf 1535  df-sb 1639  df-eu 2160  df-mo 2161  df-clab 2283  df-cleq 2289  df-clel 2292  df-nfc 2421  df-ne 2461  df-nel 2462  df-ral 2561  df-rex 2562  df-reu 2563  df-rmo 2564  df-rab 2565  df-v 2803  df-sbc 3005  df-csb 3095  df-dif 3168  df-un 3170  df-in 3172  df-ss 3179  df-pss 3181  df-nul 3469  df-if 3579  df-pw 3640  df-sn 3659  df-pr 3660  df-tp 3661  df-op 3662  df-uni 3844  df-int 3879  df-iun 3923  df-br 4040  df-opab 4094  df-mpt 4095  df-tr 4130  df-eprel 4321  df-id 4325  df-po 4330  df-so 4331  df-fr 4368  df-se 4369  df-we 4370  df-ord 4411  df-on 4412  df-lim 4413  df-suc 4414  df-om 4673  df-xp 4711  df-rel 4712  df-cnv 4713  df-co 4714  df-dm 4715  df-rn 4716  df-res 4717  df-ima 4718  df-iota 5235  df-fun 5273  df-fn 5274  df-f 5275  df-f1 5276  df-fo 5277  df-f1o 5278  df-fv 5279  df-isom 5280  df-ov 5877  df-oprab 5878  df-mpt2 5879  df-1st 6138  df-2nd 6139  df-riota 6320  df-recs 6404  df-rdg 6439  df-1o 6495  df-oadd 6499  df-er 6676  df-en 6880  df-dom 6881  df-sdom 6882  df-fin 6883  df-sup 7210  df-oi 7241  df-card 7588  df-pnf 8885  df-mnf 8886  df-xr 8887  df-ltxr 8888  df-le 8889  df-sub 9055  df-neg 9056  df-div 9440  df-nn 9763  df-2 9820  df-3 9821  df-n0 9982  df-z 10041  df-uz 10247  df-rp 10371  df-fz 10799  df-fzo 10887  df-fl 10941  df-mod 10990  df-seq 11063  df-exp 11121  df-hash 11354  df-cj 11600  df-re 11601  df-im 11602  df-sqr 11736  df-abs 11737  df-clim 11978  df-sum 12175  df-dvds 12548  df-bits 12629
  Copyright terms: Public domain W3C validator