Metamath Proof Explorer


Theorem modcyc2

Description: The modulo operation is periodic. (Contributed by NM, 12-Nov-2008)

Ref Expression
Assertion modcyc2 A B + N A B N mod B = A mod B

Proof

Step Hyp Ref Expression
1 recn A A
2 rpcn B + B
3 zcn N N
4 mulneg1 N B -N B = N B
5 4 ancoms B N -N B = N B
6 mulcom B N B N = N B
7 6 negeqd B N B N = N B
8 5 7 eqtr4d B N -N B = B N
9 8 3adant1 A B N -N B = B N
10 9 oveq2d A B N A + -N B = A + B N
11 mulcl B N B N
12 negsub A B N A + B N = A B N
13 11 12 sylan2 A B N A + B N = A B N
14 13 3impb A B N A + B N = A B N
15 10 14 eqtr2d A B N A B N = A + -N B
16 1 2 3 15 syl3an A B + N A B N = A + -N B
17 16 oveq1d A B + N A B N mod B = A + -N B mod B
18 znegcl N N
19 modcyc A B + N A + -N B mod B = A mod B
20 18 19 syl3an3 A B + N A + -N B mod B = A mod B
21 17 20 eqtrd A B + N A B N mod B = A mod B