Metamath Proof Explorer


Theorem nummac

Description: Perform a multiply-add of two decimal integers M and N against a fixed multiplicand P (with carry). (Contributed by Mario Carneiro, 18-Feb-2014)

Ref Expression
Hypotheses numma.1
|- T e. NN0
numma.2
|- A e. NN0
numma.3
|- B e. NN0
numma.4
|- C e. NN0
numma.5
|- D e. NN0
numma.6
|- M = ( ( T x. A ) + B )
numma.7
|- N = ( ( T x. C ) + D )
nummac.8
|- P e. NN0
nummac.9
|- F e. NN0
nummac.10
|- G e. NN0
nummac.11
|- ( ( A x. P ) + ( C + G ) ) = E
nummac.12
|- ( ( B x. P ) + D ) = ( ( T x. G ) + F )
Assertion nummac
|- ( ( M x. P ) + N ) = ( ( T x. E ) + F )

Proof

Step Hyp Ref Expression
1 numma.1
 |-  T e. NN0
2 numma.2
 |-  A e. NN0
3 numma.3
 |-  B e. NN0
4 numma.4
 |-  C e. NN0
5 numma.5
 |-  D e. NN0
6 numma.6
 |-  M = ( ( T x. A ) + B )
7 numma.7
 |-  N = ( ( T x. C ) + D )
8 nummac.8
 |-  P e. NN0
9 nummac.9
 |-  F e. NN0
10 nummac.10
 |-  G e. NN0
11 nummac.11
 |-  ( ( A x. P ) + ( C + G ) ) = E
12 nummac.12
 |-  ( ( B x. P ) + D ) = ( ( T x. G ) + F )
13 1 nn0cni
 |-  T e. CC
14 2 nn0cni
 |-  A e. CC
15 8 nn0cni
 |-  P e. CC
16 14 15 mulcli
 |-  ( A x. P ) e. CC
17 4 nn0cni
 |-  C e. CC
18 10 nn0cni
 |-  G e. CC
19 16 17 18 addassi
 |-  ( ( ( A x. P ) + C ) + G ) = ( ( A x. P ) + ( C + G ) )
20 19 11 eqtri
 |-  ( ( ( A x. P ) + C ) + G ) = E
21 16 17 addcli
 |-  ( ( A x. P ) + C ) e. CC
22 21 18 addcli
 |-  ( ( ( A x. P ) + C ) + G ) e. CC
23 20 22 eqeltrri
 |-  E e. CC
24 13 23 18 subdii
 |-  ( T x. ( E - G ) ) = ( ( T x. E ) - ( T x. G ) )
25 24 oveq1i
 |-  ( ( T x. ( E - G ) ) + ( ( T x. G ) + F ) ) = ( ( ( T x. E ) - ( T x. G ) ) + ( ( T x. G ) + F ) )
26 23 18 21 subadd2i
 |-  ( ( E - G ) = ( ( A x. P ) + C ) <-> ( ( ( A x. P ) + C ) + G ) = E )
27 20 26 mpbir
 |-  ( E - G ) = ( ( A x. P ) + C )
28 27 eqcomi
 |-  ( ( A x. P ) + C ) = ( E - G )
29 1 2 3 4 5 6 7 8 28 12 numma
 |-  ( ( M x. P ) + N ) = ( ( T x. ( E - G ) ) + ( ( T x. G ) + F ) )
30 13 23 mulcli
 |-  ( T x. E ) e. CC
31 13 18 mulcli
 |-  ( T x. G ) e. CC
32 npcan
 |-  ( ( ( T x. E ) e. CC /\ ( T x. G ) e. CC ) -> ( ( ( T x. E ) - ( T x. G ) ) + ( T x. G ) ) = ( T x. E ) )
33 30 31 32 mp2an
 |-  ( ( ( T x. E ) - ( T x. G ) ) + ( T x. G ) ) = ( T x. E )
34 33 oveq1i
 |-  ( ( ( ( T x. E ) - ( T x. G ) ) + ( T x. G ) ) + F ) = ( ( T x. E ) + F )
35 30 31 subcli
 |-  ( ( T x. E ) - ( T x. G ) ) e. CC
36 9 nn0cni
 |-  F e. CC
37 35 31 36 addassi
 |-  ( ( ( ( T x. E ) - ( T x. G ) ) + ( T x. G ) ) + F ) = ( ( ( T x. E ) - ( T x. G ) ) + ( ( T x. G ) + F ) )
38 34 37 eqtr3i
 |-  ( ( T x. E ) + F ) = ( ( ( T x. E ) - ( T x. G ) ) + ( ( T x. G ) + F ) )
39 25 29 38 3eqtr4i
 |-  ( ( M x. P ) + N ) = ( ( T x. E ) + F )