Metamath Proof Explorer


Theorem nn0mullong

Description: Standard algorithm (also known as "long multiplication" or "grade-school multiplication") to calculate the product of two nonnegative integers a and b by multiplying the multiplicand b by each digit of the multiplier a and then add up all the properly shifted results. Here, the binary representation of the multiplier a is used, i.e., the above mentioned "digits" are 0 or 1. This is a similar result as provided by smumul . (Contributed by AV, 7-Jun-2020)

Ref Expression
Assertion nn0mullong A0B0AB=k0..^#b A kdigit2A2kB

Proof

Step Hyp Ref Expression
1 nn0sumshdig A0A=k0..^#b A kdigit2A2k
2 1 adantr A0B0A=k0..^#b A kdigit2A2k
3 2 oveq1d A0B0AB=k0..^#b A kdigit2A2k B
4 fzofi 0..^#b A Fin
5 4 a1i A0B00..^#b A Fin
6 nn0cn B0B
7 6 adantl A0B0B
8 2nn 2
9 8 a1i A0B0k0..^#b A 2
10 elfzoelz k0..^#b A k
11 10 adantl A0B0k0..^#b A k
12 nn0rp0 A0A0+∞
13 12 adantr A0B0A0+∞
14 13 adantr A0B0k0..^#b A A0+∞
15 digvalnn0 2kA0+∞kdigit2A0
16 9 11 14 15 syl3anc A0B0k0..^#b A kdigit2A0
17 16 nn0cnd A0B0k0..^#b A kdigit2A
18 2nn0 20
19 18 a1i k0..^#b A 20
20 elfzonn0 k0..^#b A k0
21 19 20 nn0expcld k0..^#b A 2k0
22 21 nn0cnd k0..^#b A 2k
23 22 adantl A0B0k0..^#b A 2k
24 17 23 mulcld A0B0k0..^#b A kdigit2A2k
25 5 7 24 fsummulc1 A0B0k0..^#b A kdigit2A2k B = k0..^#b Akdigit2A2kB
26 3 25 eqtrd A0B0AB=k0..^#b A kdigit2A2kB