Metamath Proof Explorer


Theorem modaddmodlo

Description: The sum of an integer modulo a positive integer and another integer equals the sum of the two integers modulo the positive integer if the other integer is in the lower part of the range between 0 and the positive integer. (Contributed by AV, 30-Oct-2018)

Ref Expression
Assertion modaddmodlo A M B 0 ..^ M A mod M B + A mod M = B + A mod M

Proof

Step Hyp Ref Expression
1 elfzoelz B 0 ..^ M A mod M B
2 1 zred B 0 ..^ M A mod M B
3 2 adantr B 0 ..^ M A mod M A M B
4 zmodcl A M A mod M 0
5 4 nn0red A M A mod M
6 5 adantl B 0 ..^ M A mod M A M A mod M
7 3 6 readdcld B 0 ..^ M A mod M A M B + A mod M
8 7 ancoms A M B 0 ..^ M A mod M B + A mod M
9 nnrp M M +
10 9 ad2antlr A M B 0 ..^ M A mod M M +
11 2 adantl A M B 0 ..^ M A mod M B
12 5 adantr A M B 0 ..^ M A mod M A mod M
13 elfzole1 B 0 ..^ M A mod M 0 B
14 13 adantl A M B 0 ..^ M A mod M 0 B
15 4 nn0ge0d A M 0 A mod M
16 15 adantr A M B 0 ..^ M A mod M 0 A mod M
17 11 12 14 16 addge0d A M B 0 ..^ M A mod M 0 B + A mod M
18 elfzolt2 B 0 ..^ M A mod M B < M A mod M
19 18 adantl A M B 0 ..^ M A mod M B < M A mod M
20 nnre M M
21 20 ad2antlr A M B 0 ..^ M A mod M M
22 11 12 21 ltaddsubd A M B 0 ..^ M A mod M B + A mod M < M B < M A mod M
23 19 22 mpbird A M B 0 ..^ M A mod M B + A mod M < M
24 modid B + A mod M M + 0 B + A mod M B + A mod M < M B + A mod M mod M = B + A mod M
25 8 10 17 23 24 syl22anc A M B 0 ..^ M A mod M B + A mod M mod M = B + A mod M
26 zre A A
27 26 adantr A M A
28 27 adantr A M B 0 ..^ M A mod M A
29 modadd2mod A B M + B + A mod M mod M = B + A mod M
30 28 11 10 29 syl3anc A M B 0 ..^ M A mod M B + A mod M mod M = B + A mod M
31 25 30 eqtr3d A M B 0 ..^ M A mod M B + A mod M = B + A mod M
32 31 ex A M B 0 ..^ M A mod M B + A mod M = B + A mod M