Metamath Proof Explorer


Theorem modcyc

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

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

Proof

Step Hyp Ref Expression
1 zre N N
2 rpre B + B
3 remulcl N B N B
4 1 2 3 syl2an N B + N B
5 readdcl A N B A + N B
6 4 5 sylan2 A N B + A + N B
7 6 3impb A N B + A + N B
8 simp3 A N B + B +
9 modval A + N B B + A + N B mod B = A + N B - B A + N B B
10 7 8 9 syl2anc A N B + A + N B mod B = A + N B - B A + N B B
11 recn A A
12 11 3ad2ant1 A N B + A
13 4 recnd N B + N B
14 13 3adant1 A N B + N B
15 rpcnne0 B + B B 0
16 15 3ad2ant3 A N B + B B 0
17 divdir A N B B B 0 A + N B B = A B + N B B
18 12 14 16 17 syl3anc A N B + A + N B B = A B + N B B
19 zcn N N
20 divcan4 N B B 0 N B B = N
21 20 3expb N B B 0 N B B = N
22 19 15 21 syl2an N B + N B B = N
23 22 3adant1 A N B + N B B = N
24 23 oveq2d A N B + A B + N B B = A B + N
25 18 24 eqtrd A N B + A + N B B = A B + N
26 25 fveq2d A N B + A + N B B = A B + N
27 rerpdivcl A B + A B
28 27 3adant2 A N B + A B
29 simp2 A N B + N
30 fladdz A B N A B + N = A B + N
31 28 29 30 syl2anc A N B + A B + N = A B + N
32 26 31 eqtrd A N B + A + N B B = A B + N
33 32 oveq2d A N B + B A + N B B = B A B + N
34 rpcn B + B
35 34 3ad2ant3 A N B + B
36 reflcl A B A B
37 36 recnd A B A B
38 27 37 syl A B + A B
39 38 3adant2 A N B + A B
40 19 3ad2ant2 A N B + N
41 35 39 40 adddid A N B + B A B + N = B A B + B N
42 mulcom N B N B = B N
43 19 34 42 syl2an N B + N B = B N
44 43 3adant1 A N B + N B = B N
45 44 eqcomd A N B + B N = N B
46 45 oveq2d A N B + B A B + B N = B A B + N B
47 33 41 46 3eqtrd A N B + B A + N B B = B A B + N B
48 47 oveq2d A N B + A + N B - B A + N B B = A + N B - B A B + N B
49 34 adantl A B + B
50 49 38 mulcld A B + B A B
51 50 3adant2 A N B + B A B
52 12 51 14 pnpcan2d A N B + A + N B - B A B + N B = A B A B
53 10 48 52 3eqtrd A N B + A + N B mod B = A B A B
54 modval A B + A mod B = A B A B
55 54 3adant2 A N B + A mod B = A B A B
56 53 55 eqtr4d A N B + A + N B mod B = A mod B
57 56 3com23 A B + N A + N B mod B = A mod B