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

Theorem bitsinv1 12946
Description: There is an explicit inverse to the bits function for nonnegative integers (which can be extended to negative integers using bitscmp 12942), 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 oveq2 6081 . . . . . . . . . . 11  |-  ( x  =  0  ->  (
0..^ x )  =  ( 0..^ 0 ) )
2 fzo0 11151 . . . . . . . . . . 11  |-  ( 0..^ 0 )  =  (/)
31, 2syl6eq 2483 . . . . . . . . . 10  |-  ( x  =  0  ->  (
0..^ x )  =  (/) )
43ineq2d 3534 . . . . . . . . 9  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (/) ) )
5 in0 3645 . . . . . . . . 9  |-  ( (bits `  N )  i^i  (/) )  =  (/)
64, 5syl6eq 2483 . . . . . . . 8  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  (/) )
76sumeq1d 12487 . . . . . . 7  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
8 sum0 12507 . . . . . . 7  |-  sum_ n  e.  (/)  ( 2 ^ n )  =  0
97, 8syl6eq 2483 . . . . . 6  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  0 )
10 oveq2 6081 . . . . . . . 8  |-  ( x  =  0  ->  (
2 ^ x )  =  ( 2 ^ 0 ) )
11 2cn 10062 . . . . . . . . 9  |-  2  e.  CC
12 exp0 11378 . . . . . . . . 9  |-  ( 2  e.  CC  ->  (
2 ^ 0 )  =  1 )
1311, 12ax-mp 8 . . . . . . . 8  |-  ( 2 ^ 0 )  =  1
1410, 13syl6eq 2483 . . . . . . 7  |-  ( x  =  0  ->  (
2 ^ x )  =  1 )
1514oveq2d 6089 . . . . . 6  |-  ( x  =  0  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  1
) )
169, 15eqeq12d 2449 . . . . 5  |-  ( x  =  0  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  0  =  ( N  mod  1
) ) )
1716imbi2d 308 . . . 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 ) ) ) )
18 oveq2 6081 . . . . . . . 8  |-  ( x  =  k  ->  (
0..^ x )  =  ( 0..^ k ) )
1918ineq2d 3534 . . . . . . 7  |-  ( x  =  k  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ k ) ) )
2019sumeq1d 12487 . . . . . 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 ) )
21 oveq2 6081 . . . . . . 7  |-  ( x  =  k  ->  (
2 ^ x )  =  ( 2 ^ k ) )
2221oveq2d 6089 . . . . . 6  |-  ( x  =  k  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ k ) ) )
2320, 22eqeq12d 2449 . . . . 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
) ) ) )
2423imbi2d 308 . . . 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 ) ) ) ) )
25 oveq2 6081 . . . . . . . 8  |-  ( x  =  ( k  +  1 )  ->  (
0..^ x )  =  ( 0..^ ( k  +  1 ) ) )
2625ineq2d 3534 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) )
2726sumeq1d 12487 . . . . . 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 ) )
28 oveq2 6081 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
2 ^ x )  =  ( 2 ^ ( k  +  1 ) ) )
2928oveq2d 6089 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ ( k  +  1 ) ) ) )
3027, 29eqeq12d 2449 . . . . 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 ) ) ) ) )
3130imbi2d 308 . . . 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 ) ) ) ) ) )
32 oveq2 6081 . . . . . . . 8  |-  ( x  =  N  ->  (
0..^ x )  =  ( 0..^ N ) )
3332ineq2d 3534 . . . . . . 7  |-  ( x  =  N  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ N ) ) )
3433sumeq1d 12487 . . . . . 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 ) )
35 oveq2 6081 . . . . . . 7  |-  ( x  =  N  ->  (
2 ^ x )  =  ( 2 ^ N ) )
3635oveq2d 6089 . . . . . 6  |-  ( x  =  N  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ N ) ) )
3734, 36eqeq12d 2449 . . . . 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
) ) ) )
3837imbi2d 308 . . . 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 ) ) ) ) )
39 nn0z 10296 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ZZ )
40 zmod10 11256 . . . . . 6  |-  ( N  e.  ZZ  ->  ( N  mod  1 )  =  0 )
4139, 40syl 16 . . . . 5  |-  ( N  e.  NN0  ->  ( N  mod  1 )  =  0 )
4241eqcomd 2440 . . . 4  |-  ( N  e.  NN0  ->  0  =  ( N  mod  1
) )
43 oveq1 6080 . . . . . . 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
) ) )
44 fzonel 11144 . . . . . . . . . . . . 13  |-  -.  k  e.  ( 0..^ k )
4544a1i 11 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  -.  k  e.  (
0..^ k ) )
46 disjsn 3860 . . . . . . . . . . . 12  |-  ( ( ( 0..^ k )  i^i  { k } )  =  (/)  <->  -.  k  e.  ( 0..^ k ) )
4745, 46sylibr 204 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( 0..^ k )  i^i  { k } )  =  (/) )
4847ineq2d 3534 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  ( (bits `  N )  i^i  (/) ) )
49 inindi 3550 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  i^i  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  i^i  ( (bits `  N
)  i^i  { k } ) )
5048, 49, 53eqtr3g 2490 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( (bits `  N )  i^i  (
0..^ k ) )  i^i  ( (bits `  N )  i^i  {
k } ) )  =  (/) )
51 simpr 448 . . . . . . . . . . . . 13  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  NN0 )
52 nn0uz 10512 . . . . . . . . . . . . 13  |-  NN0  =  ( ZZ>= `  0 )
5351, 52syl6eleq 2525 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  ( ZZ>= ` 
0 ) )
54 fzosplitsn 11187 . . . . . . . . . . . 12  |-  ( k  e.  ( ZZ>= `  0
)  ->  ( 0..^ ( k  +  1 ) )  =  ( ( 0..^ k )  u.  { k } ) )
5553, 54syl 16 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( 0..^ ( k  +  1 ) )  =  ( ( 0..^ k )  u.  {
k } ) )
5655ineq2d 3534 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( (bits `  N
)  i^i  ( (
0..^ k )  u. 
{ k } ) ) )
57 indi 3579 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  u.  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  u.  ( (bits `  N
)  i^i  { k } ) )
5856, 57syl6eq 2483 . . . . . . . . 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 } ) ) )
59 fzofi 11305 . . . . . . . . . . 11  |-  ( 0..^ ( k  +  1 ) )  e.  Fin
60 inss2 3554 . . . . . . . . . . 11  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) 
C_  ( 0..^ ( k  +  1 ) )
61 ssfi 7321 . . . . . . . . . . 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 )
6259, 60, 61mp2an 654 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) )  e.  Fin
6362a1i 11 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  e. 
Fin )
64 2nn 10125 . . . . . . . . . . . 12  |-  2  e.  NN
6564a1i 11 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  2  e.  NN )
66 simpr 448 . . . . . . . . . . . . . 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 ) ) ) )
6760, 66sseldi 3338 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( 0..^ ( k  +  1 ) ) )
68 elfzouz 11136 . . . . . . . . . . . . 13  |-  ( n  e.  ( 0..^ ( k  +  1 ) )  ->  n  e.  ( ZZ>= `  0 )
)
6967, 68syl 16 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( ZZ>= `  0 )
)
7069, 52syl6eleqr 2526 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  NN0 )
7165, 70nnexpcld 11536 . . . . . . . . . 10  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  NN )
7271nncnd 10008 . . . . . . . . 9  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  CC )
7350, 58, 63, 72fsumsplit 12525 . . . . . . . 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 ) ) )
74 bitsinv1lem 12945 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
7539, 74sylan 458 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
76 eqeq2 2444 . . . . . . . . . . 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 ) ) )
77 eqeq2 2444 . . . . . . . . . . 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 ) ) )
78 simpr 448 . . . . . . . . . . . . . . 15  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
k  e.  (bits `  N ) )
7978snssd 3935 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  { k }  C_  (bits `  N ) )
80 dfss1 3537 . . . . . . . . . . . . . 14  |-  ( { k }  C_  (bits `  N )  <->  ( (bits `  N )  i^i  {
k } )  =  { k } )
8179, 80sylib 189 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( (bits `  N
)  i^i  { k } )  =  {
k } )
8281sumeq1d 12487 . . . . . . . . . . . 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 ) )
83 simplr 732 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
k  e.  NN0 )
8464a1i 11 . . . . . . . . . . . . . . 15  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
2  e.  NN )
8584, 83nnexpcld 11536 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  NN )
8685nncnd 10008 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  CC )
87 oveq2 6081 . . . . . . . . . . . . . 14  |-  ( n  =  k  ->  (
2 ^ n )  =  ( 2 ^ k ) )
8887sumsn 12526 . . . . . . . . . . . . 13  |-  ( ( k  e.  NN0  /\  ( 2 ^ k
)  e.  CC )  ->  sum_ n  e.  {
k }  ( 2 ^ n )  =  ( 2 ^ k
) )
8983, 86, 88syl2anc 643 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  { k }  ( 2 ^ n )  =  ( 2 ^ k ) )
9082, 89eqtrd 2467 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  ( 2 ^ k ) )
91 simpr 448 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  -.  k  e.  (bits `  N ) )
92 disjsn 3860 . . . . . . . . . . . . . 14  |-  ( ( (bits `  N )  i^i  { k } )  =  (/)  <->  -.  k  e.  (bits `  N ) )
9391, 92sylibr 204 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  -> 
( (bits `  N
)  i^i  { k } )  =  (/) )
9493sumeq1d 12487 . . . . . . . . . . . 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
) )
9594, 8syl6eq 2483 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  0 )
9676, 77, 90, 95ifbothda 3761 . . . . . . . . . 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 ) )
9796oveq2d 6089 . . . . . . . . 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 ) ) )
9875, 97eqtr4d 2470 . . . . . . . 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
) ) )
9973, 98eqeq12d 2449 . . . . . . 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
) ) ) )
10043, 99syl5ibr 213 . . . . . 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 ) ) ) ) )
101100expcom 425 . . . . 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 ) ) ) ) ) )
102101a2d 24 . . . 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 ) ) ) ) ) )
10317, 24, 31, 38, 42, 102nn0ind 10358 . . 3  |-  ( N  e.  NN0  ->  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) ) )
104103pm2.43i 45 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) )
105 id 20 . . . . . . 7  |-  ( N  e.  NN0  ->  N  e. 
NN0 )
106105, 52syl6eleq 2525 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ( ZZ>= `  0 )
)
10764a1i 11 . . . . . . . 8  |-  ( N  e.  NN0  ->  2  e.  NN )
108107, 105nnexpcld 11536 . . . . . . 7  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  NN )
109108nnzd 10366 . . . . . 6  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  ZZ )
110 2z 10304 . . . . . . . 8  |-  2  e.  ZZ
111 uzid 10492 . . . . . . . 8  |-  ( 2  e.  ZZ  ->  2  e.  ( ZZ>= `  2 )
)
112110, 111ax-mp 8 . . . . . . 7  |-  2  e.  ( ZZ>= `  2 )
113 bernneq3 11499 . . . . . . 7  |-  ( ( 2  e.  ( ZZ>= ` 
2 )  /\  N  e.  NN0 )  ->  N  <  ( 2 ^ N
) )
114112, 113mpan 652 . . . . . 6  |-  ( N  e.  NN0  ->  N  < 
( 2 ^ N
) )
115 elfzo2 11135 . . . . . 6  |-  ( N  e.  ( 0..^ ( 2 ^ N ) )  <->  ( N  e.  ( ZZ>= `  0 )  /\  ( 2 ^ N
)  e.  ZZ  /\  N  <  ( 2 ^ N ) ) )
116106, 109, 114, 115syl3anbrc 1138 . . . . 5  |-  ( N  e.  NN0  ->  N  e.  ( 0..^ ( 2 ^ N ) ) )
117 bitsfzo 12939 . . . . . 6  |-  ( ( N  e.  ZZ  /\  N  e.  NN0 )  -> 
( N  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  N
)  C_  ( 0..^ N ) ) )
11839, 105, 117syl2anc 643 . . . . 5  |-  ( N  e.  NN0  ->  ( N  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  N )  C_  ( 0..^ N ) ) )
119116, 118mpbid 202 . . . 4  |-  ( N  e.  NN0  ->  (bits `  N )  C_  (
0..^ N ) )
120 df-ss 3326 . . . 4  |-  ( (bits `  N )  C_  (
0..^ N )  <->  ( (bits `  N )  i^i  (
0..^ N ) )  =  (bits `  N
) )
121119, 120sylib 189 . . 3  |-  ( N  e.  NN0  ->  ( (bits `  N )  i^i  (
0..^ N ) )  =  (bits `  N
) )
122121sumeq1d 12487 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  sum_ n  e.  (bits `  N ) ( 2 ^ n ) )
123 nn0re 10222 . . 3  |-  ( N  e.  NN0  ->  N  e.  RR )
124 2rp 10609 . . . . 5  |-  2  e.  RR+
125124a1i 11 . . . 4  |-  ( N  e.  NN0  ->  2  e.  RR+ )
126125, 39rpexpcld 11538 . . 3  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  RR+ )
127 nn0ge0 10239 . . 3  |-  ( N  e.  NN0  ->  0  <_  N )
128 modid 11262 . . 3  |-  ( ( ( N  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  /\  ( 0  <_  N  /\  N  <  ( 2 ^ N ) ) )  ->  ( N  mod  ( 2 ^ N
) )  =  N )
129123, 126, 127, 114, 128syl22anc 1185 . 2  |-  ( N  e.  NN0  ->  ( N  mod  ( 2 ^ N ) )  =  N )
130104, 122, 1293eqtr3d 2475 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 177    /\ wa 359    = wceq 1652    e. wcel 1725    u. cun 3310    i^i cin 3311    C_ wss 3312   (/)c0 3620   ifcif 3731   {csn 3806   class class class wbr 4204   ` cfv 5446  (class class class)co 6073   Fincfn 7101   CCcc 8980   RRcr 8981   0cc0 8982   1c1 8983    + caddc 8985    < clt 9112    <_ cle 9113   NNcn 9992   2c2 10041   NN0cn0 10213   ZZcz 10274   ZZ>=cuz 10480   RR+crp 10604  ..^cfzo 11127    mod cmo 11242   ^cexp 11374   sum_csu 12471  bitscbits 12923
This theorem is referenced by:  bitsinv2  12947  bitsf1ocnv  12948
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1555  ax-5 1566  ax-17 1626  ax-9 1666  ax-8 1687  ax-13 1727  ax-14 1729  ax-6 1744  ax-7 1749  ax-11 1761  ax-12 1950  ax-ext 2416  ax-rep 4312  ax-sep 4322  ax-nul 4330  ax-pow 4369  ax-pr 4395  ax-un 4693  ax-inf2 7588  ax-cnex 9038  ax-resscn 9039  ax-1cn 9040  ax-icn 9041  ax-addcl 9042  ax-addrcl 9043  ax-mulcl 9044  ax-mulrcl 9045  ax-mulcom 9046  ax-addass 9047  ax-mulass 9048  ax-distr 9049  ax-i2m1 9050  ax-1ne0 9051  ax-1rid 9052  ax-rnegex 9053  ax-rrecex 9054  ax-cnre 9055  ax-pre-lttri 9056  ax-pre-lttrn 9057  ax-pre-ltadd 9058  ax-pre-mulgt0 9059  ax-pre-sup 9060
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1328  df-ex 1551  df-nf 1554  df-sb 1659  df-eu 2284  df-mo 2285  df-clab 2422  df-cleq 2428  df-clel 2431  df-nfc 2560  df-ne 2600  df-nel 2601  df-ral 2702  df-rex 2703  df-reu 2704  df-rmo 2705  df-rab 2706  df-v 2950  df-sbc 3154  df-csb 3244  df-dif 3315  df-un 3317  df-in 3319  df-ss 3326  df-pss 3328  df-nul 3621  df-if 3732  df-pw 3793  df-sn 3812  df-pr 3813  df-tp 3814  df-op 3815  df-uni 4008  df-int 4043  df-iun 4087  df-br 4205  df-opab 4259  df-mpt 4260  df-tr 4295  df-eprel 4486  df-id 4490  df-po 4495  df-so 4496  df-fr 4533  df-se 4534  df-we 4535  df-ord 4576  df-on 4577  df-lim 4578  df-suc 4579  df-om 4838  df-xp 4876  df-rel 4877  df-cnv 4878  df-co 4879  df-dm 4880  df-rn 4881  df-res 4882  df-ima 4883  df-iota 5410  df-fun 5448  df-fn 5449  df-f 5450  df-f1 5451  df-fo 5452  df-f1o 5453  df-fv 5454  df-isom 5455  df-ov 6076  df-oprab 6077  df-mpt2 6078  df-1st 6341  df-2nd 6342  df-riota 6541  df-recs 6625  df-rdg 6660  df-1o 6716  df-oadd 6720  df-er 6897  df-en 7102  df-dom 7103  df-sdom 7104  df-fin 7105  df-sup 7438  df-oi 7471  df-card 7818  df-pnf 9114  df-mnf 9115  df-xr 9116  df-ltxr 9117  df-le 9118  df-sub 9285  df-neg 9286  df-div 9670  df-nn 9993  df-2 10050  df-3 10051  df-n0 10214  df-z 10275  df-uz 10481  df-rp 10605  df-fz 11036  df-fzo 11128  df-fl 11194  df-mod 11243  df-seq 11316  df-exp 11375  df-hash 11611  df-cj 11896  df-re 11897  df-im 11898  df-sqr 12032  df-abs 12033  df-clim 12274  df-sum 12472  df-dvds 12845  df-bits 12926
  Copyright terms: Public domain W3C validator