Metamath Proof Explorer


Theorem smumul

Description: For sequences that correspond to valid integers, the sequence multiplication function produces the sequence for the product. This is effectively a proof of the correctness of the multiplication process, implemented in terms of logic gates for df-sad , whose correctness is verified in sadadd .

Outside this range, the sequences cannot be representing integers, but the smul function still "works". This extended function is best interpreted in terms of the ring structure of the 2-adic integers. (Contributed by Mario Carneiro, 22-Sep-2016)

Ref Expression
Assertion smumul A B bits A smul bits B = bits A B

Proof

Step Hyp Ref Expression
1 bitsss bits A 0
2 bitsss bits B 0
3 smucl bits A 0 bits B 0 bits A smul bits B 0
4 1 2 3 mp2an bits A smul bits B 0
5 4 sseli k bits A smul bits B k 0
6 5 a1i A B k bits A smul bits B k 0
7 bitsss bits A B 0
8 7 sseli k bits A B k 0
9 8 a1i A B k bits A B k 0
10 simpll A B k 0 A
11 simplr A B k 0 B
12 simpr A B k 0 k 0
13 1nn0 1 0
14 13 a1i A B k 0 1 0
15 12 14 nn0addcld A B k 0 k + 1 0
16 10 11 15 smumullem A B k 0 bits A 0 ..^ k + 1 smul bits B = bits A mod 2 k + 1 B
17 16 ineq1d A B k 0 bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1 = bits A mod 2 k + 1 B 0 ..^ k + 1
18 2nn 2
19 18 a1i A B k 0 2
20 19 15 nnexpcld A B k 0 2 k + 1
21 10 20 zmodcld A B k 0 A mod 2 k + 1 0
22 21 nn0zd A B k 0 A mod 2 k + 1
23 22 11 zmulcld A B k 0 A mod 2 k + 1 B
24 bitsmod A mod 2 k + 1 B k + 1 0 bits A mod 2 k + 1 B mod 2 k + 1 = bits A mod 2 k + 1 B 0 ..^ k + 1
25 23 15 24 syl2anc A B k 0 bits A mod 2 k + 1 B mod 2 k + 1 = bits A mod 2 k + 1 B 0 ..^ k + 1
26 17 25 eqtr4d A B k 0 bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1 = bits A mod 2 k + 1 B mod 2 k + 1
27 inass bits A 0 ..^ k + 1 0 ..^ k + 1 = bits A 0 ..^ k + 1 0 ..^ k + 1
28 inidm 0 ..^ k + 1 0 ..^ k + 1 = 0 ..^ k + 1
29 28 ineq2i bits A 0 ..^ k + 1 0 ..^ k + 1 = bits A 0 ..^ k + 1
30 27 29 eqtri bits A 0 ..^ k + 1 0 ..^ k + 1 = bits A 0 ..^ k + 1
31 30 oveq1i bits A 0 ..^ k + 1 0 ..^ k + 1 smul bits B 0 ..^ k + 1 = bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1
32 31 ineq1i bits A 0 ..^ k + 1 0 ..^ k + 1 smul bits B 0 ..^ k + 1 0 ..^ k + 1 = bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1 0 ..^ k + 1
33 inss1 bits A 0 ..^ k + 1 bits A
34 1 a1i A B k 0 bits A 0
35 33 34 sstrid A B k 0 bits A 0 ..^ k + 1 0
36 2 a1i A B k 0 bits B 0
37 35 36 15 smueq A B k 0 bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1 = bits A 0 ..^ k + 1 0 ..^ k + 1 smul bits B 0 ..^ k + 1 0 ..^ k + 1
38 34 36 15 smueq A B k 0 bits A smul bits B 0 ..^ k + 1 = bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1 0 ..^ k + 1
39 32 37 38 3eqtr4a A B k 0 bits A 0 ..^ k + 1 smul bits B 0 ..^ k + 1 = bits A smul bits B 0 ..^ k + 1
40 20 nnrpd A B k 0 2 k + 1 +
41 10 zred A B k 0 A
42 modabs2 A 2 k + 1 + A mod 2 k + 1 mod 2 k + 1 = A mod 2 k + 1
43 41 40 42 syl2anc A B k 0 A mod 2 k + 1 mod 2 k + 1 = A mod 2 k + 1
44 eqidd A B k 0 B mod 2 k + 1 = B mod 2 k + 1
45 22 10 11 11 40 43 44 modmul12d A B k 0 A mod 2 k + 1 B mod 2 k + 1 = A B mod 2 k + 1
46 45 fveq2d A B k 0 bits A mod 2 k + 1 B mod 2 k + 1 = bits A B mod 2 k + 1
47 26 39 46 3eqtr3d A B k 0 bits A smul bits B 0 ..^ k + 1 = bits A B mod 2 k + 1
48 10 11 zmulcld A B k 0 A B
49 bitsmod A B k + 1 0 bits A B mod 2 k + 1 = bits A B 0 ..^ k + 1
50 48 15 49 syl2anc A B k 0 bits A B mod 2 k + 1 = bits A B 0 ..^ k + 1
51 47 50 eqtrd A B k 0 bits A smul bits B 0 ..^ k + 1 = bits A B 0 ..^ k + 1
52 51 eleq2d A B k 0 k bits A smul bits B 0 ..^ k + 1 k bits A B 0 ..^ k + 1
53 elin k bits A smul bits B 0 ..^ k + 1 k bits A smul bits B k 0 ..^ k + 1
54 elin k bits A B 0 ..^ k + 1 k bits A B k 0 ..^ k + 1
55 52 53 54 3bitr3g A B k 0 k bits A smul bits B k 0 ..^ k + 1 k bits A B k 0 ..^ k + 1
56 nn0uz 0 = 0
57 12 56 eleqtrdi A B k 0 k 0
58 eluzfz2b k 0 k 0 k
59 57 58 sylib A B k 0 k 0 k
60 12 nn0zd A B k 0 k
61 fzval3 k 0 k = 0 ..^ k + 1
62 60 61 syl A B k 0 0 k = 0 ..^ k + 1
63 59 62 eleqtrd A B k 0 k 0 ..^ k + 1
64 63 biantrud A B k 0 k bits A smul bits B k bits A smul bits B k 0 ..^ k + 1
65 63 biantrud A B k 0 k bits A B k bits A B k 0 ..^ k + 1
66 55 64 65 3bitr4d A B k 0 k bits A smul bits B k bits A B
67 66 ex A B k 0 k bits A smul bits B k bits A B
68 6 9 67 pm5.21ndd A B k bits A smul bits B k bits A B
69 68 eqrdv A B bits A smul bits B = bits A B