Metamath Proof Explorer


Theorem modsubdir

Description: Distribute the modulo operation over a subtraction. (Contributed by NM, 30-Dec-2008)

Ref Expression
Assertion modsubdir A B C + B mod C A mod C A B mod C = A mod C B mod C

Proof

Step Hyp Ref Expression
1 modcl A C + A mod C
2 1 3adant2 A B C + A mod C
3 modcl B C + B mod C
4 3 3adant1 A B C + B mod C
5 2 4 subge0d A B C + 0 A mod C B mod C B mod C A mod C
6 resubcl A B A B
7 6 3adant3 A B C + A B
8 simp3 A B C + C +
9 rerpdivcl A C + A C
10 9 flcld A C + A C
11 10 3adant2 A B C + A C
12 rerpdivcl B C + B C
13 12 flcld B C + B C
14 13 3adant1 A B C + B C
15 11 14 zsubcld A B C + A C B C
16 modcyc2 A B C + A C B C A - B - C A C B C mod C = A B mod C
17 7 8 15 16 syl3anc A B C + A - B - C A C B C mod C = A B mod C
18 recn A A
19 18 3ad2ant1 A B C + A
20 recn B B
21 20 3ad2ant2 A B C + B
22 rpre C + C
23 22 adantl A C + C
24 refldivcl A C + A C
25 23 24 remulcld A C + C A C
26 25 recnd A C + C A C
27 26 3adant2 A B C + C A C
28 22 adantl B C + C
29 refldivcl B C + B C
30 28 29 remulcld B C + C B C
31 30 recnd B C + C B C
32 31 3adant1 A B C + C B C
33 19 21 27 32 sub4d A B C + A - B - C A C C B C = A - C A C - B C B C
34 22 3ad2ant3 A B C + C
35 34 recnd A B C + C
36 24 recnd A C + A C
37 36 3adant2 A B C + A C
38 29 recnd B C + B C
39 38 3adant1 A B C + B C
40 35 37 39 subdid A B C + C A C B C = C A C C B C
41 40 oveq2d A B C + A - B - C A C B C = A - B - C A C C B C
42 modval A C + A mod C = A C A C
43 42 3adant2 A B C + A mod C = A C A C
44 modval B C + B mod C = B C B C
45 44 3adant1 A B C + B mod C = B C B C
46 43 45 oveq12d A B C + A mod C B mod C = A - C A C - B C B C
47 33 41 46 3eqtr4d A B C + A - B - C A C B C = A mod C B mod C
48 47 oveq1d A B C + A - B - C A C B C mod C = A mod C B mod C mod C
49 17 48 eqtr3d A B C + A B mod C = A mod C B mod C mod C
50 49 adantr A B C + 0 A mod C B mod C A B mod C = A mod C B mod C mod C
51 2 4 resubcld A B C + A mod C B mod C
52 51 adantr A B C + 0 A mod C B mod C A mod C B mod C
53 simpl3 A B C + 0 A mod C B mod C C +
54 simpr A B C + 0 A mod C B mod C 0 A mod C B mod C
55 modge0 B C + 0 B mod C
56 55 3adant1 A B C + 0 B mod C
57 2 4 subge02d A B C + 0 B mod C A mod C B mod C A mod C
58 56 57 mpbid A B C + A mod C B mod C A mod C
59 modlt A C + A mod C < C
60 59 3adant2 A B C + A mod C < C
61 51 2 34 58 60 lelttrd A B C + A mod C B mod C < C
62 61 adantr A B C + 0 A mod C B mod C A mod C B mod C < C
63 modid A mod C B mod C C + 0 A mod C B mod C A mod C B mod C < C A mod C B mod C mod C = A mod C B mod C
64 52 53 54 62 63 syl22anc A B C + 0 A mod C B mod C A mod C B mod C mod C = A mod C B mod C
65 50 64 eqtrd A B C + 0 A mod C B mod C A B mod C = A mod C B mod C
66 modge0 A B C + 0 A B mod C
67 6 66 stoic3 A B C + 0 A B mod C
68 67 adantr A B C + A B mod C = A mod C B mod C 0 A B mod C
69 simpr A B C + A B mod C = A mod C B mod C A B mod C = A mod C B mod C
70 68 69 breqtrd A B C + A B mod C = A mod C B mod C 0 A mod C B mod C
71 65 70 impbida A B C + 0 A mod C B mod C A B mod C = A mod C B mod C
72 5 71 bitr3d A B C + B mod C A mod C A B mod C = A mod C B mod C