Metamath Proof Explorer


Theorem congr

Description: Definition of congruence by integer multiple (see ProofWiki "Congruence (Number Theory)", 11-Jul-2021, https://proofwiki.org/wiki/Definition:Congruence_(Number_Theory) ): An integer A is congruent to an integer B modulo M if their difference is a multiple of M . See also the definition in ApostolNT p. 104: "... a is congruent to b modulo m , and we write a == b (mod m ) if m divides the difference a - b ", or Wikipedia "Modular arithmetic - Congruence", https://en.wikipedia.org/wiki/Modular_arithmetic#Congruence , 11-Jul-2021,: "Given an integer n > 1, called a modulus, two integers are said to be congruent modulo n, if n is a divisor of their difference (i.e., if there is an integer k such that a-b = kn)". (Contributed by AV, 11-Jul-2021)

Ref Expression
Assertion congr
|- ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> ( ( A mod M ) = ( B mod M ) <-> E. n e. ZZ ( n x. M ) = ( A - B ) ) )

Proof

Step Hyp Ref Expression
1 moddvds
 |-  ( ( M e. NN /\ A e. ZZ /\ B e. ZZ ) -> ( ( A mod M ) = ( B mod M ) <-> M || ( A - B ) ) )
2 1 3coml
 |-  ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> ( ( A mod M ) = ( B mod M ) <-> M || ( A - B ) ) )
3 simp3
 |-  ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> M e. NN )
4 3 nnzd
 |-  ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> M e. ZZ )
5 zsubcl
 |-  ( ( A e. ZZ /\ B e. ZZ ) -> ( A - B ) e. ZZ )
6 5 3adant3
 |-  ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> ( A - B ) e. ZZ )
7 divides
 |-  ( ( M e. ZZ /\ ( A - B ) e. ZZ ) -> ( M || ( A - B ) <-> E. n e. ZZ ( n x. M ) = ( A - B ) ) )
8 4 6 7 syl2anc
 |-  ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> ( M || ( A - B ) <-> E. n e. ZZ ( n x. M ) = ( A - B ) ) )
9 2 8 bitrd
 |-  ( ( A e. ZZ /\ B e. ZZ /\ M e. NN ) -> ( ( A mod M ) = ( B mod M ) <-> E. n e. ZZ ( n x. M ) = ( A - B ) ) )