Metamath Proof Explorer


Theorem bitsinvp1

Description: Recursive definition of the inverse of the bits function. (Contributed by Mario Carneiro, 8-Sep-2016)

Ref Expression
Hypothesis bitsinv.k K = bits 0 -1
Assertion bitsinvp1 A 0 N 0 K A 0 ..^ N + 1 = K A 0 ..^ N + if N A 2 N 0

Proof

Step Hyp Ref Expression
1 bitsinv.k K = bits 0 -1
2 fzonel ¬ N 0 ..^ N
3 2 a1i A 0 N 0 ¬ N 0 ..^ N
4 disjsn 0 ..^ N N = ¬ N 0 ..^ N
5 3 4 sylibr A 0 N 0 0 ..^ N N =
6 5 ineq2d A 0 N 0 A 0 ..^ N N = A
7 inindi A 0 ..^ N N = A 0 ..^ N A N
8 in0 A =
9 6 7 8 3eqtr3g A 0 N 0 A 0 ..^ N A N =
10 simpr A 0 N 0 N 0
11 nn0uz 0 = 0
12 10 11 eleqtrdi A 0 N 0 N 0
13 fzosplitsn N 0 0 ..^ N + 1 = 0 ..^ N N
14 12 13 syl A 0 N 0 0 ..^ N + 1 = 0 ..^ N N
15 14 ineq2d A 0 N 0 A 0 ..^ N + 1 = A 0 ..^ N N
16 indi A 0 ..^ N N = A 0 ..^ N A N
17 15 16 eqtrdi A 0 N 0 A 0 ..^ N + 1 = A 0 ..^ N A N
18 fzofi 0 ..^ N + 1 Fin
19 18 a1i A 0 N 0 0 ..^ N + 1 Fin
20 inss2 A 0 ..^ N + 1 0 ..^ N + 1
21 ssfi 0 ..^ N + 1 Fin A 0 ..^ N + 1 0 ..^ N + 1 A 0 ..^ N + 1 Fin
22 19 20 21 sylancl A 0 N 0 A 0 ..^ N + 1 Fin
23 2nn 2
24 23 a1i A 0 N 0 k A 0 ..^ N + 1 2
25 inss1 A 0 ..^ N + 1 A
26 simpl A 0 N 0 A 0
27 25 26 sstrid A 0 N 0 A 0 ..^ N + 1 0
28 27 sselda A 0 N 0 k A 0 ..^ N + 1 k 0
29 24 28 nnexpcld A 0 N 0 k A 0 ..^ N + 1 2 k
30 29 nncnd A 0 N 0 k A 0 ..^ N + 1 2 k
31 9 17 22 30 fsumsplit A 0 N 0 k A 0 ..^ N + 1 2 k = k A 0 ..^ N 2 k + k A N 2 k
32 elfpw A 0 ..^ N + 1 𝒫 0 Fin A 0 ..^ N + 1 0 A 0 ..^ N + 1 Fin
33 27 22 32 sylanbrc A 0 N 0 A 0 ..^ N + 1 𝒫 0 Fin
34 1 bitsinv A 0 ..^ N + 1 𝒫 0 Fin K A 0 ..^ N + 1 = k A 0 ..^ N + 1 2 k
35 33 34 syl A 0 N 0 K A 0 ..^ N + 1 = k A 0 ..^ N + 1 2 k
36 inss1 A 0 ..^ N A
37 36 26 sstrid A 0 N 0 A 0 ..^ N 0
38 fzofi 0 ..^ N Fin
39 38 a1i A 0 N 0 0 ..^ N Fin
40 inss2 A 0 ..^ N 0 ..^ N
41 ssfi 0 ..^ N Fin A 0 ..^ N 0 ..^ N A 0 ..^ N Fin
42 39 40 41 sylancl A 0 N 0 A 0 ..^ N Fin
43 elfpw A 0 ..^ N 𝒫 0 Fin A 0 ..^ N 0 A 0 ..^ N Fin
44 37 42 43 sylanbrc A 0 N 0 A 0 ..^ N 𝒫 0 Fin
45 1 bitsinv A 0 ..^ N 𝒫 0 Fin K A 0 ..^ N = k A 0 ..^ N 2 k
46 44 45 syl A 0 N 0 K A 0 ..^ N = k A 0 ..^ N 2 k
47 snssi N A N A
48 47 adantl A 0 N 0 N A N A
49 sseqin2 N A A N = N
50 48 49 sylib A 0 N 0 N A A N = N
51 50 sumeq1d A 0 N 0 N A k A N 2 k = k N 2 k
52 simpr A 0 N 0 N A N A
53 23 a1i A 0 N 0 N A 2
54 simplr A 0 N 0 N A N 0
55 53 54 nnexpcld A 0 N 0 N A 2 N
56 55 nncnd A 0 N 0 N A 2 N
57 oveq2 k = N 2 k = 2 N
58 57 sumsn N A 2 N k N 2 k = 2 N
59 52 56 58 syl2anc A 0 N 0 N A k N 2 k = 2 N
60 51 59 eqtr2d A 0 N 0 N A 2 N = k A N 2 k
61 simpr A 0 N 0 ¬ N A ¬ N A
62 disjsn A N = ¬ N A
63 61 62 sylibr A 0 N 0 ¬ N A A N =
64 63 sumeq1d A 0 N 0 ¬ N A k A N 2 k = k 2 k
65 sum0 k 2 k = 0
66 64 65 eqtr2di A 0 N 0 ¬ N A 0 = k A N 2 k
67 60 66 ifeqda A 0 N 0 if N A 2 N 0 = k A N 2 k
68 46 67 oveq12d A 0 N 0 K A 0 ..^ N + if N A 2 N 0 = k A 0 ..^ N 2 k + k A N 2 k
69 31 35 68 3eqtr4d A 0 N 0 K A 0 ..^ N + 1 = K A 0 ..^ N + if N A 2 N 0