Metamath Proof Explorer


Theorem moddvds

Description: Two ways to say A == B (mod N ), see also definition in ApostolNT p. 106. (Contributed by Mario Carneiro, 18-Feb-2014)

Ref Expression
Assertion moddvds N A B A mod N = B mod N N A B

Proof

Step Hyp Ref Expression
1 nnrp N N +
2 1 adantr N A B N +
3 0mod N + 0 mod N = 0
4 2 3 syl N A B 0 mod N = 0
5 4 eqeq2d N A B A B mod N = 0 mod N A B mod N = 0
6 zre A A
7 6 ad2antrl N A B A
8 zre B B
9 8 ad2antll N A B B
10 9 renegcld N A B B
11 modadd1 A B B N + A mod N = B mod N A + B mod N = B + B mod N
12 11 3expia A B B N + A mod N = B mod N A + B mod N = B + B mod N
13 7 9 10 2 12 syl22anc N A B A mod N = B mod N A + B mod N = B + B mod N
14 7 recnd N A B A
15 9 recnd N A B B
16 14 15 negsubd N A B A + B = A B
17 16 oveq1d N A B A + B mod N = A B mod N
18 15 negidd N A B B + B = 0
19 18 oveq1d N A B B + B mod N = 0 mod N
20 17 19 eqeq12d N A B A + B mod N = B + B mod N A B mod N = 0 mod N
21 13 20 sylibd N A B A mod N = B mod N A B mod N = 0 mod N
22 7 9 resubcld N A B A B
23 0red N A B 0
24 modadd1 A B 0 B N + A B mod N = 0 mod N A - B + B mod N = 0 + B mod N
25 24 3expia A B 0 B N + A B mod N = 0 mod N A - B + B mod N = 0 + B mod N
26 22 23 9 2 25 syl22anc N A B A B mod N = 0 mod N A - B + B mod N = 0 + B mod N
27 14 15 npcand N A B A - B + B = A
28 27 oveq1d N A B A - B + B mod N = A mod N
29 15 addid2d N A B 0 + B = B
30 29 oveq1d N A B 0 + B mod N = B mod N
31 28 30 eqeq12d N A B A - B + B mod N = 0 + B mod N A mod N = B mod N
32 26 31 sylibd N A B A B mod N = 0 mod N A mod N = B mod N
33 21 32 impbid N A B A mod N = B mod N A B mod N = 0 mod N
34 zsubcl A B A B
35 dvdsval3 N A B N A B A B mod N = 0
36 34 35 sylan2 N A B N A B A B mod N = 0
37 5 33 36 3bitr4d N A B A mod N = B mod N N A B
38 37 3impb N A B A mod N = B mod N N A B