Metamath Proof Explorer


Theorem modaddabs

Description: Absorption law for modulo. (Contributed by Paul Chapman, 22-Jun-2011)

Ref Expression
Assertion modaddabs
|- ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( A mod C ) + ( B mod C ) ) mod C ) = ( ( A + B ) mod C ) )

Proof

Step Hyp Ref Expression
1 modcl
 |-  ( ( A e. RR /\ C e. RR+ ) -> ( A mod C ) e. RR )
2 1 recnd
 |-  ( ( A e. RR /\ C e. RR+ ) -> ( A mod C ) e. CC )
3 2 3adant2
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( A mod C ) e. CC )
4 modcl
 |-  ( ( B e. RR /\ C e. RR+ ) -> ( B mod C ) e. RR )
5 4 recnd
 |-  ( ( B e. RR /\ C e. RR+ ) -> ( B mod C ) e. CC )
6 5 3adant1
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( B mod C ) e. CC )
7 3 6 addcomd
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( A mod C ) + ( B mod C ) ) = ( ( B mod C ) + ( A mod C ) ) )
8 7 oveq1d
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( A mod C ) + ( B mod C ) ) mod C ) = ( ( ( B mod C ) + ( A mod C ) ) mod C ) )
9 simpl
 |-  ( ( B e. RR /\ C e. RR+ ) -> B e. RR )
10 4 9 jca
 |-  ( ( B e. RR /\ C e. RR+ ) -> ( ( B mod C ) e. RR /\ B e. RR ) )
11 10 3adant1
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( B mod C ) e. RR /\ B e. RR ) )
12 simpr
 |-  ( ( A e. RR /\ C e. RR+ ) -> C e. RR+ )
13 1 12 jca
 |-  ( ( A e. RR /\ C e. RR+ ) -> ( ( A mod C ) e. RR /\ C e. RR+ ) )
14 13 3adant2
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( A mod C ) e. RR /\ C e. RR+ ) )
15 modabs2
 |-  ( ( B e. RR /\ C e. RR+ ) -> ( ( B mod C ) mod C ) = ( B mod C ) )
16 15 3adant1
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( B mod C ) mod C ) = ( B mod C ) )
17 modadd1
 |-  ( ( ( ( B mod C ) e. RR /\ B e. RR ) /\ ( ( A mod C ) e. RR /\ C e. RR+ ) /\ ( ( B mod C ) mod C ) = ( B mod C ) ) -> ( ( ( B mod C ) + ( A mod C ) ) mod C ) = ( ( B + ( A mod C ) ) mod C ) )
18 11 14 16 17 syl3anc
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( B mod C ) + ( A mod C ) ) mod C ) = ( ( B + ( A mod C ) ) mod C ) )
19 recn
 |-  ( B e. RR -> B e. CC )
20 19 3ad2ant2
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> B e. CC )
21 3 20 addcomd
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( A mod C ) + B ) = ( B + ( A mod C ) ) )
22 21 oveq1d
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( A mod C ) + B ) mod C ) = ( ( B + ( A mod C ) ) mod C ) )
23 18 22 eqtr4d
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( B mod C ) + ( A mod C ) ) mod C ) = ( ( ( A mod C ) + B ) mod C ) )
24 simpl
 |-  ( ( A e. RR /\ C e. RR+ ) -> A e. RR )
25 1 24 jca
 |-  ( ( A e. RR /\ C e. RR+ ) -> ( ( A mod C ) e. RR /\ A e. RR ) )
26 25 3adant2
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( A mod C ) e. RR /\ A e. RR ) )
27 3simpc
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( B e. RR /\ C e. RR+ ) )
28 modabs2
 |-  ( ( A e. RR /\ C e. RR+ ) -> ( ( A mod C ) mod C ) = ( A mod C ) )
29 28 3adant2
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( A mod C ) mod C ) = ( A mod C ) )
30 modadd1
 |-  ( ( ( ( A mod C ) e. RR /\ A e. RR ) /\ ( B e. RR /\ C e. RR+ ) /\ ( ( A mod C ) mod C ) = ( A mod C ) ) -> ( ( ( A mod C ) + B ) mod C ) = ( ( A + B ) mod C ) )
31 26 27 29 30 syl3anc
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( A mod C ) + B ) mod C ) = ( ( A + B ) mod C ) )
32 8 23 31 3eqtrd
 |-  ( ( A e. RR /\ B e. RR /\ C e. RR+ ) -> ( ( ( A mod C ) + ( B mod C ) ) mod C ) = ( ( A + B ) mod C ) )