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 AMB0..^MAmodMB+AmodM=B+AmodM

Proof

Step Hyp Ref Expression
1 elfzoelz B0..^MAmodMB
2 1 zred B0..^MAmodMB
3 2 adantr B0..^MAmodMAMB
4 zmodcl AMAmodM0
5 4 nn0red AMAmodM
6 5 adantl B0..^MAmodMAMAmodM
7 3 6 readdcld B0..^MAmodMAMB+AmodM
8 7 ancoms AMB0..^MAmodMB+AmodM
9 nnrp MM+
10 9 ad2antlr AMB0..^MAmodMM+
11 2 adantl AMB0..^MAmodMB
12 5 adantr AMB0..^MAmodMAmodM
13 elfzole1 B0..^MAmodM0B
14 13 adantl AMB0..^MAmodM0B
15 4 nn0ge0d AM0AmodM
16 15 adantr AMB0..^MAmodM0AmodM
17 11 12 14 16 addge0d AMB0..^MAmodM0B+AmodM
18 elfzolt2 B0..^MAmodMB<MAmodM
19 18 adantl AMB0..^MAmodMB<MAmodM
20 nnre MM
21 20 ad2antlr AMB0..^MAmodMM
22 11 12 21 ltaddsubd AMB0..^MAmodMB+AmodM<MB<MAmodM
23 19 22 mpbird AMB0..^MAmodMB+AmodM<M
24 modid B+AmodMM+0B+AmodMB+AmodM<MB+AmodMmodM=B+AmodM
25 8 10 17 23 24 syl22anc AMB0..^MAmodMB+AmodMmodM=B+AmodM
26 zre AA
27 26 adantr AMA
28 27 adantr AMB0..^MAmodMA
29 modadd2mod ABM+B+AmodMmodM=B+AmodM
30 28 11 10 29 syl3anc AMB0..^MAmodMB+AmodMmodM=B+AmodM
31 25 30 eqtr3d AMB0..^MAmodMB+AmodM=B+AmodM
32 31 ex AMB0..^MAmodMB+AmodM=B+AmodM