Metamath Proof Explorer


Theorem addmodid

Description: The sum of a positive integer and a nonnegative integer less than the positive integer is equal to the nonnegative integer modulo the positive integer. (Contributed by Alexander van der Vekens, 30-Oct-2018) (Proof shortened by AV, 5-Jul-2020)

Ref Expression
Assertion addmodid A 0 M A < M M + A mod M = A

Proof

Step Hyp Ref Expression
1 nncn M M
2 1 mulid2d M 1 M = M
3 2 3ad2ant2 A 0 M A < M 1 M = M
4 3 eqcomd A 0 M A < M M = 1 M
5 4 oveq1d A 0 M A < M M + A = 1 M + A
6 5 oveq1d A 0 M A < M M + A mod M = 1 M + A mod M
7 1zzd A 0 M A < M 1
8 nnrp M M +
9 8 3ad2ant2 A 0 M A < M M +
10 nn0re A 0 A
11 10 rexrd A 0 A *
12 11 3ad2ant1 A 0 M A < M A *
13 nn0ge0 A 0 0 A
14 13 3ad2ant1 A 0 M A < M 0 A
15 simp3 A 0 M A < M A < M
16 0xr 0 *
17 nnre M M
18 17 rexrd M M *
19 18 3ad2ant2 A 0 M A < M M *
20 elico1 0 * M * A 0 M A * 0 A A < M
21 16 19 20 sylancr A 0 M A < M A 0 M A * 0 A A < M
22 12 14 15 21 mpbir3and A 0 M A < M A 0 M
23 muladdmodid 1 M + A 0 M 1 M + A mod M = A
24 7 9 22 23 syl3anc A 0 M A < M 1 M + A mod M = A
25 6 24 eqtrd A 0 M A < M M + A mod M = A