Metamath Proof Explorer


Theorem sadcadd

Description: Non-recursive definition of the carry sequence. (Contributed by Mario Carneiro, 8-Sep-2016)

Ref Expression
Hypotheses sadval.a φ A 0
sadval.b φ B 0
sadval.c C = seq 0 c 2 𝑜 , m 0 if cadd m A m B c 1 𝑜 n 0 if n = 0 n 1
sadcp1.n φ N 0
sadcadd.k K = bits 0 -1
Assertion sadcadd φ C N 2 N K A 0 ..^ N + K B 0 ..^ N

Proof

Step Hyp Ref Expression
1 sadval.a φ A 0
2 sadval.b φ B 0
3 sadval.c C = seq 0 c 2 𝑜 , m 0 if cadd m A m B c 1 𝑜 n 0 if n = 0 n 1
4 sadcp1.n φ N 0
5 sadcadd.k K = bits 0 -1
6 fveq2 x = 0 C x = C 0
7 6 eleq2d x = 0 C x C 0
8 oveq2 x = 0 2 x = 2 0
9 2cn 2
10 exp0 2 2 0 = 1
11 9 10 ax-mp 2 0 = 1
12 8 11 eqtrdi x = 0 2 x = 1
13 oveq2 x = 0 0 ..^ x = 0 ..^ 0
14 fzo0 0 ..^ 0 =
15 13 14 eqtrdi x = 0 0 ..^ x =
16 15 ineq2d x = 0 A 0 ..^ x = A
17 in0 A =
18 16 17 eqtrdi x = 0 A 0 ..^ x =
19 18 fveq2d x = 0 K A 0 ..^ x = K
20 0nn0 0 0
21 fvres 0 0 bits 0 0 = bits 0
22 20 21 ax-mp bits 0 0 = bits 0
23 0bits bits 0 =
24 22 23 eqtr2i = bits 0 0
25 5 24 fveq12i K = bits 0 -1 bits 0 0
26 bitsf1o bits 0 : 0 1-1 onto 𝒫 0 Fin
27 f1ocnvfv1 bits 0 : 0 1-1 onto 𝒫 0 Fin 0 0 bits 0 -1 bits 0 0 = 0
28 26 20 27 mp2an bits 0 -1 bits 0 0 = 0
29 25 28 eqtri K = 0
30 19 29 eqtrdi x = 0 K A 0 ..^ x = 0
31 15 ineq2d x = 0 B 0 ..^ x = B
32 in0 B =
33 31 32 eqtrdi x = 0 B 0 ..^ x =
34 33 fveq2d x = 0 K B 0 ..^ x = K
35 34 29 eqtrdi x = 0 K B 0 ..^ x = 0
36 30 35 oveq12d x = 0 K A 0 ..^ x + K B 0 ..^ x = 0 + 0
37 00id 0 + 0 = 0
38 36 37 eqtrdi x = 0 K A 0 ..^ x + K B 0 ..^ x = 0
39 12 38 breq12d x = 0 2 x K A 0 ..^ x + K B 0 ..^ x 1 0
40 7 39 bibi12d x = 0 C x 2 x K A 0 ..^ x + K B 0 ..^ x C 0 1 0
41 40 imbi2d x = 0 φ C x 2 x K A 0 ..^ x + K B 0 ..^ x φ C 0 1 0
42 fveq2 x = k C x = C k
43 42 eleq2d x = k C x C k
44 oveq2 x = k 2 x = 2 k
45 oveq2 x = k 0 ..^ x = 0 ..^ k
46 45 ineq2d x = k A 0 ..^ x = A 0 ..^ k
47 46 fveq2d x = k K A 0 ..^ x = K A 0 ..^ k
48 45 ineq2d x = k B 0 ..^ x = B 0 ..^ k
49 48 fveq2d x = k K B 0 ..^ x = K B 0 ..^ k
50 47 49 oveq12d x = k K A 0 ..^ x + K B 0 ..^ x = K A 0 ..^ k + K B 0 ..^ k
51 44 50 breq12d x = k 2 x K A 0 ..^ x + K B 0 ..^ x 2 k K A 0 ..^ k + K B 0 ..^ k
52 43 51 bibi12d x = k C x 2 x K A 0 ..^ x + K B 0 ..^ x C k 2 k K A 0 ..^ k + K B 0 ..^ k
53 52 imbi2d x = k φ C x 2 x K A 0 ..^ x + K B 0 ..^ x φ C k 2 k K A 0 ..^ k + K B 0 ..^ k
54 fveq2 x = k + 1 C x = C k + 1
55 54 eleq2d x = k + 1 C x C k + 1
56 oveq2 x = k + 1 2 x = 2 k + 1
57 oveq2 x = k + 1 0 ..^ x = 0 ..^ k + 1
58 57 ineq2d x = k + 1 A 0 ..^ x = A 0 ..^ k + 1
59 58 fveq2d x = k + 1 K A 0 ..^ x = K A 0 ..^ k + 1
60 57 ineq2d x = k + 1 B 0 ..^ x = B 0 ..^ k + 1
61 60 fveq2d x = k + 1 K B 0 ..^ x = K B 0 ..^ k + 1
62 59 61 oveq12d x = k + 1 K A 0 ..^ x + K B 0 ..^ x = K A 0 ..^ k + 1 + K B 0 ..^ k + 1
63 56 62 breq12d x = k + 1 2 x K A 0 ..^ x + K B 0 ..^ x 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
64 55 63 bibi12d x = k + 1 C x 2 x K A 0 ..^ x + K B 0 ..^ x C k + 1 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
65 64 imbi2d x = k + 1 φ C x 2 x K A 0 ..^ x + K B 0 ..^ x φ C k + 1 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
66 fveq2 x = N C x = C N
67 66 eleq2d x = N C x C N
68 oveq2 x = N 2 x = 2 N
69 oveq2 x = N 0 ..^ x = 0 ..^ N
70 69 ineq2d x = N A 0 ..^ x = A 0 ..^ N
71 70 fveq2d x = N K A 0 ..^ x = K A 0 ..^ N
72 69 ineq2d x = N B 0 ..^ x = B 0 ..^ N
73 72 fveq2d x = N K B 0 ..^ x = K B 0 ..^ N
74 71 73 oveq12d x = N K A 0 ..^ x + K B 0 ..^ x = K A 0 ..^ N + K B 0 ..^ N
75 68 74 breq12d x = N 2 x K A 0 ..^ x + K B 0 ..^ x 2 N K A 0 ..^ N + K B 0 ..^ N
76 67 75 bibi12d x = N C x 2 x K A 0 ..^ x + K B 0 ..^ x C N 2 N K A 0 ..^ N + K B 0 ..^ N
77 76 imbi2d x = N φ C x 2 x K A 0 ..^ x + K B 0 ..^ x φ C N 2 N K A 0 ..^ N + K B 0 ..^ N
78 1 2 3 sadc0 φ ¬ C 0
79 0lt1 0 < 1
80 0re 0
81 1re 1
82 80 81 ltnlei 0 < 1 ¬ 1 0
83 79 82 mpbi ¬ 1 0
84 83 a1i φ ¬ 1 0
85 78 84 2falsed φ C 0 1 0
86 1 ad2antrr φ k 0 C k 2 k K A 0 ..^ k + K B 0 ..^ k A 0
87 2 ad2antrr φ k 0 C k 2 k K A 0 ..^ k + K B 0 ..^ k B 0
88 simplr φ k 0 C k 2 k K A 0 ..^ k + K B 0 ..^ k k 0
89 simpr φ k 0 C k 2 k K A 0 ..^ k + K B 0 ..^ k C k 2 k K A 0 ..^ k + K B 0 ..^ k
90 86 87 3 88 5 89 sadcaddlem φ k 0 C k 2 k K A 0 ..^ k + K B 0 ..^ k C k + 1 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
91 90 ex φ k 0 C k 2 k K A 0 ..^ k + K B 0 ..^ k C k + 1 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
92 91 expcom k 0 φ C k 2 k K A 0 ..^ k + K B 0 ..^ k C k + 1 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
93 92 a2d k 0 φ C k 2 k K A 0 ..^ k + K B 0 ..^ k φ C k + 1 2 k + 1 K A 0 ..^ k + 1 + K B 0 ..^ k + 1
94 41 53 65 77 85 93 nn0ind N 0 φ C N 2 N K A 0 ..^ N + K B 0 ..^ N
95 4 94 mpcom φ C N 2 N K A 0 ..^ N + K B 0 ..^ N