[Next][Prev] [Right] [Left] [Up] [Index] [Root]

Residue Class Rings

The ring Z/mZ consists of representatives for the residue classes

of integers modulo m > 1. This online help node and the nodes below it describe the operations in Magma for such rings and their elements.

Subsections

Representation

At any stage during a session, Magma will have at most one copy of Z/mZ present, for any m>1. In other words, different names for the same residue class ring will in fact be different references to the same structure. This saves memory and avoids confusion about different but isomorphic structures.

If m is a prime number, the ring Z/mZ forms a field; however, Magma has special functions for dealing with finite fields. The operations described here should not be used for

finite field calculations: the implementation of finite field arithmetic in Magma takes full advantage of the special structure of finite fields and leads to superior performance.

Coercion

Automatic coercion takes place between Z/mZ and Z so that a binary operation like + applied to an element of Z/mZ and an integer will result in a residue class from Z/mZ.

Using !, elements from a prime field GF(p) can be coerced into Z/pZ, and elements from Z/pZ can be coerced into GF(p^r). Also, transitions between Z/mZ and Z/nZ can be made using ! provided that m divides n or n divides m. In cases where there is a choice -- such as when an element r from Z/mZ is coerced into Z/nZ with m dividing n -- the result will be the residue class containing the representative for r.


Example RngInt_Coercion (H38E5)

> r := ResidueClassRing(3) ! 5;
> r;
2
> ResidueClassRing(6) ! r;
2
So the representative 2 of 5 mod 3 is mapped to the residue class 2 mod 6, and not to 5 mod 6.

Homomorphisms

Ring homomorphisms with domain Z/mZ are completely determined by the image of 1. As usual, we require our homomorphisms to map 1 to 1. Therefore, the general homomorphism constructor with domain Z/mZ needs no arguments.

hom< R -> S | > : RngIntRes, Rng -> Map
Given a residue class ring R, and a ring S, create a homomorphism from R to S, determined by f(1_R) = 1_S. Note that it is the responsibility of the user that the map defines a homomorphism!

Creation Functions

One(R) : RngIntRes -> RngIntResElt
Identity(R) : RngIntRes -> RngIntResElt
Zero(R) : RngIntRes -> RngIntResElt
Representative(R) : RngIntRes -> RngIntResElt
These generic functions create 1, 1, 0, and 0 respectively, in any Z/mZ.
ResidueClassRing(m) : RngIntElt -> RngIntRes
IntegerRing(m) : RngIntElt -> RngIntRes
Integers(m) : RngIntElt -> RngIntRes
RingOfIntegers(m) : RngIntElt -> RngIntRes
Create the residue class ring Z/mZ.
ResidueClassRing(Q) : RngIntEltFact -> RngIntRes
IntegerRing(Q) : RngIntEltFact -> RngIntRes
Integers(Q) : RngIntEltFact -> RngIntRes
Create the residue class ring Z/mZ, where m is the integer corresponding to the factorization sequence Q. This is more efficient than creating the ring by m alone, since the factorization Q will be stored so it can be reused later.
quo< Z | I > : RngInt, RngInt -> RngIntRes
Given the ring of integers Z, and an ideal I, create the residue class ring modulo the ideal.
quo< Z | m > : RngInt, RngIntElt -> RngIntRes
Given the ring of integers Z, and an integer m>1, create the residue class ring Z/mZ.
elt< R | k > : RngIntRes, RngIntElt -> RngIntResElt
Create the residue class containing the integer k in residue class ring R.
R ! k : RngIntRes, RngIntElt -> RngIntResElt
Create the residue class containing k in the residue class ring R. Here k is allowed to be either an integer, or an element of the finite field F_p in the case R = Z/pZ, or an element of S = Z/nZ for a multiple or divisor n of m (with R = Z/mZ).
Random(R) : RngIntRes -> RngIntResElt
Create a `random' residue class in R.

Structure Operations

Category(R) : RngIntRes -> Cat
Parent(R) : RngIntRes -> PowerStructure
PrimeRing(R) : RngIntRes -> RngIntRes
Center(R) : RngIntRes -> RngIntRes
AdditiveGroup(R) : RngIntRes -> GrpAb, Map
Given R=Z/mZ, create the abelian group of integers modulo m under addition. This returns the finite additive abelian group A (of order m) together with a map from A to the ring Z/mZ, sending A.1 to 1.
MultiplicativeGroup(R) : RngIntRes -> GrpAb, Map
UnitGroup(R) : RngIntRes -> GrpAb, Map
Given R=Z/mZ, create the multiplicative group of R as an abelian group. This returns an (additive) abelian group A of order phi(m), together with a map from A to R.
sub< R | n > : RngIntRes, RngIntResElt -> RngIntRes
Given R, the ring of integers modulo m or an ideal of it, and an element n of R, create the ideal aZintersect Z of the ring of integers. Note that this creates an ideal, not just a subring.
Set(R) : RngIntRes -> SetEnum
Create the enumerated set consisting of the elements of the residue class ring R.

Numerical Invariants

Characteristic(R) : RngIntRes -> RngIntResElt
# R : RngIntRes -> RngIntResElt
Modulus(R) : RngIntRes -> RngInt
Given a residue class ring R=Z/mZ, this function returns the common modulus m for the elements of R.
FactoredModulus(R) : RngIntRes -> RngIntEltFact
Given a residue class ring R=Z/mZ, this function returns the factorization of the common modulus m for the elements of R.

Ring Predicates and Booleans

IsCommutative(R) : RngIntRes -> BoolElt
IsUnitary(R) : RngIntRes -> BoolElt
IsFinite(R) : RngIntRes -> BoolElt
IsOrdered(R) : RngIntRes -> BoolElt
IsField(R) : RngIntRes -> BoolElt
IsEuclideanDomain(R) : RngIntRes -> BoolElt
IsPID(R) : RngIntRes -> BoolElt
IsUFD(R) : RngIntRes -> BoolElt
IsDivisionRing(R) : RngIntRes -> BoolElt
IsEuclideanRing(R) : RngIntRes -> BoolElt
IsPrincipalIdealRing(R) : RngIntRes -> BoolElt
IsDomain(R) : RngIntRes -> BoolElt
R eq R : RngIntRes, Rng -> BoolElt
R ne R : RngIntRes, Rng -> BoolElt

Arithmetic Operators

+ n : RngIntResElt -> RngIntResElt
- n : RngIntResElt -> RngIntResElt
m + n : RngIntResElt, RngIntResElt -> RngIntResElt
m - n : RngIntResElt, RngIntResElt -> RngIntResElt
m * n : RngIntResElt, RngIntResElt -> RngIntResElt
n ^ k : RngIntResElt, RngIntResElt -> RngIntResElt
m / n : RngIntResElt, RngIntResElt -> RngIntResElt
m +:= n : RngIntResElt, RngIntResElt -> RngIntResElt
m -:= n : RngIntResElt, RngIntResElt -> RngIntResElt
m *:= n : RngIntResElt, RngIntResElt -> RngIntResElt
m /:= n : RngIntResElt, RngIntResElt -> RngIntResElt
m ^:= k : RngIntResElt, RngIntResElt -> RngIntResElt

Equality and Membership

m eq n : RngIntResElt, RngIntResElt -> BoolElt
m ne n : RngIntResElt, RngIntResElt -> BoolElt
n in R : RngIntResElt, Rng -> BoolElt
n notin R : RngIntResElt, Rng -> BoolElt

Parent and Category

Parent(n) : RngIntResElt -> RngIntRes
Category(n) : RngIntResElt -> Cat

Predicates on Ring Elements

IsZero(n) : RngIntResElt -> BoolElt
IsOne(n) : RngIntResElt -> BoolElt
IsMinusOne(n) : RngIntResElt -> BoolElt
IsNilpotent(n) : RngIntResElt -> BoolElt
IsIdempotent(n) : RngIntResElt -> BoolElt
IsUnit(n) : RngIntResElt -> BoolElt
IsZeroDivisor(n) : RngIntResElt -> BoolElt
IsRegular(n) : RngIntRes -> BoolElt
IsIrreducible(n) : RngIntResElt -> BoolElt
IsPrime(n) : RngIntResElt -> BoolElt
IsSquare(n) : RngIntResElt -> BoolElt, RngIntResElt
    Factorization: [ < int, int > ]     Default: [ ]
Given an element n inZ/mZ this function returns true if there exists a inZ/mZ such that a^2=n inZ/mZ, false otherwise. If n is a square, a square root a is also returned. If m is large and its prime factorization is known, the computation may be speeded up by assigning the factorization sequence for m to the optional argument Factorization.
IsPrimitive(n) : RngIntResElt -> BoolElt
Returns true if the element n inZ/mZ is primitive, that is, if it generates the multiplicative group of Z/mZ, false otherwise.

Other Element Functions

PrimitiveElement(R) : RngIntRes -> RngIntResElt
PrimitiveRoot(R) : RngIntRes -> RngIntResElt
Given R = Z/mZ, this function returns a generator for the group of units of R if this group is cyclic, and returns 0 otherwise. Thus a valid generator is only returned if m = 2, 4, p^t or 2p^t, with p an odd prime and t >= 1.
Order(a) : RngIntResElt -> RngIntElt
Given an element a belonging to Z/mZ, return the multiplicative order k >= 1 of a if a is in the unit group (Z/mZ)^*, and zero if a is not a unit.
Sqrt(a) : RngIntResElt -> RngIntResElt
SquareRoot(a) : RngIntResElt -> RngIntResElt
    Factorization: [ < int, int > ]     Default: [ ]
Given an element a of the ring Z/mZ, this function returns an element b of Z/mZ such that b^2=a inZ/mZ, if such an element exists, and an error otherwise. If m is large and its prime factorization is known, the computation may be speeded up by assigning the factorization sequence for m to the optional argument Factorization.
AllSquareRoots(a) : RngIntResElt -> [ RngIntResElt ]
AllSqrts(a) : RngIntResElt -> [ RngIntResElt ]
    Factorization: [ < int, int > ]     Default: [ ]
Return a sequence of all square roots of an element a in a residue class ring Z/mZ. If the modulus m is large and its prime factorization is known, the computation may be speeded up by assigning the factorization sequence for m to the optional argument Factorization.

Solving Linear Equations in Z/mZ

Solution(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
Given elements a and b of Z/mZ, return a solution x to the linear congruence a.x=b in Z/mZ. An error is signalled if no solution exists.

Ideal Operations

ideal< R | a_1, ..., a_r > : RngIntRes, RngIntResElt, ..., RngIntResElt -> RngIntResIdl
quo< R | a_r, ..., a_r > : RngIntRes, RngIntResElt, ..., RngIntResElt -> GenRng
R / I : RngIntRes, RngIntResIdl -> GenRng
I + J : RngIntResIdl, RngIntResIdl -> RngIntResIdl
I * J : RngIntResIdl, RngIntResIdl -> RngIntResIdl
I meet J : RngIntResIdl, RngIntResIdl -> RngIntResIdl
I / J : RngIntResIdl, RngIntResIdl -> RngIntResIdl
a in I : RngIntResElt, RngIntResIdl -> BoolElt
a notin I : RngIntResElt, RngIntResIdl -> BoolElt
I eq J : RngIntResIdl, RngIntResIdl -> BoolElt
I ne J : RngIntResIdl, RngIntResIdl -> BoolElt
I subset J : RngIntResIdl, RngIntResIdl -> BoolElt
I notsubset J : RngIntResIdl, RngIntResIdl -> BoolElt
GreatestCommonDivisor(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
Gcd(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
GCD(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
Greatest common divisor of the elements a and b of R, that is, a generator for the R-ideal (a) + (b).
GreatestCommonDivisor(Q) : [RngIntResElt] -> RngIntResElt
Gcd(Q) : [RngIntResElt] -> RngIntResElt
GCD(Q) : [RngIntResElt] -> RngIntResElt
Greatest common divisor of the sequence of elements Q, that is, a generator for the R-ideal generated by the elements in Q.
LeastCommonMultiple(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
Lcm(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
LCM(a, b) : RngIntResElt, RngIntResElt -> RngIntResElt
Least common multiple of the elements a and b of R, that is, a generator for the R-ideal (a) intersect (b).
LeastCommonMultiple(Q) : Seq(RngIntResElt) -> RngIntResElt
Lcm(Q) : Seq(RngIntResElt) -> RngIntResElt
LCM(Q) : Seq(RngIntResElt) -> RngIntResElt
Least common multiple of the sequence of elements Q, that is, a generator for the R-ideal formed by the intersection of the principal ideals generated by elements of Q.
 [Next][Prev] [Right] [Left] [Up] [Index] [Root]