Based on the modulo operations in Theorem A-2.1.1, we can derive the following properties of modulo arithmetic:
Theorem A-2.1.2 Properties of Modulo Arithmetic
For example, suppose and . Then, and are interchangeable, and and are interchangeable in modulo arithmetic as follows:
The proof of Theorem A-2.1.2 is similar to that of Theorem A-2.1.1, which we leave as an exercise for the reader.
Definition A-1.2.1 Inverse in Modulo Arithmetic
In modulo (i.e., in the world of remainders where all numbers have been divided by ), for each :
In modulo arithmetic, modulo division is different from regular numeric division. Strictly speaking, there is no such thing as modulo division because the modulo operation itself is a form of division that returns only the remainder. modulo division of by is equivalent to computing the modulo multiplication . The result of modulo division is different from that of numeric division, because modulo division always gives an integer (as it multiplies two integers modulo ), whereas numeric division gives a real number. The inverse of an integer modulo can be computed using the extended Euclidean algorithm (YouTube tutorial)
Throughout this section, we have assumed that the residues are positive integers. For example, the possible residues modulo are assumed to be . This system is called the canonical (i.e., unsigned) residue representation. On the other hand, there is also a counterpart system that assumes signed (i.e., centered) residues , where the residues are centered around and the total number of residues is the same, namely . In both systems, a modulo operation changes a given value to another value within the system’s residue range such that: (1) if the given value is bigger than the upper bound of the residue range, the value is subtracted by the modulus ; (2) if the value is smaller than the lower bound of the residue range, the value is added by the modulus . The only difference between these two (canonical and centered) systems is their upper bounds and lower bounds: and in the canonical residue system, whereas and in the centered residue system. The canonical residue representation assumes that , whereas the centered residue system assumes that .
In both systems, the same modulo property of addition, subtraction, multiplication, and division holds, which can be proved by applying the same reasoning described in §A-1.2: the same properties hold in both systems because any two congruent residues in the centered system are separated by the gaps (for some integer ) in both systems.
Also, the same property holds for an inverse: an inverse of modulo is such that .
Using a signed residue representation is useful in certain cases. In an example of canonical (i.e., unsigned) residue representation, suppose we have the relation and we know that in a given application, is guaranteed to be within the range (i.e., ). Then, = , and thus we can remove the modulo operation, simplifying the relation. Now, suppose a different example of centered (i.e., signed) residue representation where we have the relation , and we know that in a given application, is guaranteed to be within the range . Then, . However, notice that if the relation were in a canonical residue representation, then we cannot remove the modulo operation, because if is negative, then this becomes smaller than the lower bound of the canonical residue system (i.e., ), and thus a modulo reduction (i.e., addition by one or more ) is needed.
In §D-5.8, we design the FastBConvEx operation based on this beneficial property of centered residue representation: in this algorithm design, we can simplify to , because we know that .