Metamath Proof Explorer


Theorem negmod

Description: The negation of a number modulo a positive number is equal to the difference of the modulus and the number modulo the modulus. (Contributed by AV, 5-Jul-2020)

Ref Expression
Assertion negmod A N + A mod N = N A mod N

Proof

Step Hyp Ref Expression
1 rpcn N + N
2 recn A A
3 negsub N A N + A = N A
4 1 2 3 syl2anr A N + N + A = N A
5 4 eqcomd A N + N A = N + A
6 5 oveq1d A N + N A mod N = N + A mod N
7 1 mulid2d N + 1 N = N
8 7 adantl A N + 1 N = N
9 8 oveq1d A N + 1 N + A = N + A
10 9 oveq1d A N + 1 N + A mod N = N + A mod N
11 1cnd A 1
12 mulcl 1 N 1 N
13 11 1 12 syl2an A N + 1 N
14 renegcl A A
15 14 recnd A A
16 15 adantr A N + A
17 13 16 addcomd A N + 1 N + A = - A + 1 N
18 17 oveq1d A N + 1 N + A mod N = - A + 1 N mod N
19 14 adantr A N + A
20 simpr A N + N +
21 1zzd A N + 1
22 modcyc A N + 1 - A + 1 N mod N = A mod N
23 19 20 21 22 syl3anc A N + - A + 1 N mod N = A mod N
24 18 23 eqtrd A N + 1 N + A mod N = A mod N
25 6 10 24 3eqtr2rd A N + A mod N = N A mod N