Types, Category Names, and Structures

The following functions deal with types or category names and general structures. Magma has two levels of granularity when referring to types. In most cases, the coarser grained types (of type Cat) are used. Examples of these kinds of types are "polynomial rings" (RngUPol) and "finite fields" (FldFin). However, sometimes more specific typing information is sometimes useful. For instance, the algorithm used to factorize polynomials differs significantly, depending on the coefficient ring. Hence, we might wish to implement a specialized factorization algorithm polynomials over some particular ring type. Due to this need, Magma also supports extended types.

An extended type (of type ECat) can be thought of as a type taking a parameter. Using extended types, we can talk about "polynomial rings over the integers" (RngUPol[RngInt]), or "maps from the integers to the rationals" (Map[RngInt, FldRat]). Extended types can interact with normal types in all ways, and thus generally only need to be used when the extra level of information is required.

Type(x) : Elt -> Cat
Category(x) : Elt -> Cat
Given any object x, return the type (or category name) of x.
ExtendedType(x) : Elt -> ECat
ExtendedCategory(x) : Elt -> ECat
Given any object x, return the extended type (or category name) of x.
ISA(T, U) : Cat, Cat -> BoolElt
ISA(T, U) : Cat, ECat -> BoolElt
ISA(T, U) : ECat, Cat -> BoolElt
ISA(T, U) : ECat, ECat -> BoolElt
Given types (or extended types) T and U, return whether T ISA U, i.e., whether objects of type T inherit properties of type U. For example, ISA(RngInt, Rng) is true, because the ring of integers Z is a ring.
MakeType(S) : MonStgElt -> Cat
Given a string S specifying a type return the actual type corresponding to S. This is useful when some intrinsic name hides the symbol which normally refers to the actual type.
ElementType(S) : Str -> Cat
Given any structure S, return the type of the elements of S. For example, the element type of the ring of integers Z is RngIntElt since that is the type of the integers which lie in Z.
CoveringStructure(S, T) : Str, Str -> Str
Given structures S and T, return a covering structure C for S and T, so that S and T both embed into C. An error results if no such covering structure exists.
ExistsCoveringStructure(S, T) : Str, Str -> BoolElt, Str
Given structures S and T, return whether a covering structure C for S and T exists, and if so, return such a C, so that S and T both embed into C.

Example State_TypeStructures (H1E22)

We demonstrate the type and structure functions.
> Type(3);
RngIntElt
> t := MakeType("RngIntElt");
> t;
RngIntElt
> Type(3) eq t;
true
> Z := IntegerRing();
> Type(Z);
RngInt
> ElementType(Z);
RngIntElt
> ISA(RngIntElt, RngElt);
true
> ISA(RngIntElt, GrpElt);
false
> ISA(FldRat, Fld);
true
The following give examples of when covering structures exist or do not exist.
> Q := RationalField();
> CoveringStructure(Z, Q);
Rational Field
> ExistsCoveringStructure(Z, DihedralGroup(3));
false
> ExistsCoveringStructure(Z, CyclotomicField(5));
true Cyclotomic Field of order 5 and degree 4
> ExistsCoveringStructure(CyclotomicField(3), CyclotomicField(5));
true Cyclotomic Field of order 15 and degree 8
> ExistsCoveringStructure(GF(2), GF(3));
false
> ExistsCoveringStructure(GF(2^6), GF(2, 15));
true Finite field of size 2^30
Our last example demonstrates the use of extended types:
> R<x> := PolynomialRing(Integers());
> ExtendedType(R);
RngUPol[RngInt]
> ISA(RngUPol[RngInt], RngUPol);
true
> f := x + 1;
> ExtendedType(f);
RngUPolElt[RngInt]
> ISA(RngUPolElt[RngInt], RngUPolElt);
true
V2.28, 13 July 2023