Metamath Proof Explorer


Theorem modmuladd

Description: Decomposition of an integer into a multiple of a modulus and a remainder. (Contributed by AV, 14-Jul-2021)

Ref Expression
Assertion modmuladd A B 0 M M + A mod M = B k A = k M + B

Proof

Step Hyp Ref Expression
1 zre A A
2 1 adantr A M + A
3 rpre M + M
4 3 adantl A M + M
5 rpne0 M + M 0
6 5 adantl A M + M 0
7 2 4 6 redivcld A M + A M
8 7 flcld A M + A M
9 8 3adant2 A B 0 M M + A M
10 oveq1 k = A M k M = A M M
11 10 oveq1d k = A M k M + A mod M = A M M + A mod M
12 11 eqeq2d k = A M A = k M + A mod M A = A M M + A mod M
13 12 adantl A B 0 M M + k = A M A = k M + A mod M A = A M M + A mod M
14 1 anim1i A M + A M +
15 14 3adant2 A B 0 M M + A M +
16 flpmodeq A M + A M M + A mod M = A
17 15 16 syl A B 0 M M + A M M + A mod M = A
18 17 eqcomd A B 0 M M + A = A M M + A mod M
19 9 13 18 rspcedvd A B 0 M M + k A = k M + A mod M
20 oveq2 B = A mod M k M + B = k M + A mod M
21 20 eqeq2d B = A mod M A = k M + B A = k M + A mod M
22 21 eqcoms A mod M = B A = k M + B A = k M + A mod M
23 22 rexbidv A mod M = B k A = k M + B k A = k M + A mod M
24 19 23 syl5ibrcom A B 0 M M + A mod M = B k A = k M + B
25 oveq1 A = k M + B A mod M = k M + B mod M
26 simpr A B 0 M M + k k
27 simpl3 A B 0 M M + k M +
28 simpl2 A B 0 M M + k B 0 M
29 muladdmodid k M + B 0 M k M + B mod M = B
30 26 27 28 29 syl3anc A B 0 M M + k k M + B mod M = B
31 25 30 sylan9eqr A B 0 M M + k A = k M + B A mod M = B
32 31 rexlimdva2 A B 0 M M + k A = k M + B A mod M = B
33 24 32 impbid A B 0 M M + A mod M = B k A = k M + B