[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
Magmas (or Structures)

Magmas (or Structures)

The primary concept in the design of the Magma system is that of a `magma'. Following Bourbaki, a magma can be defined as a set with a law of composition.

Thus, types correspond to magmas; a collection of magmas sharing a common representation forms a category (e.g., the category of permutation groups); a collection of categories satisfying the same set of identical relations forms a variety (e.g., the variety of groups). Functors may be used to move between categories, and the variety operations (substructure, homomorphic image, and Cartesian product) are available as uniform constructors across all categories.

While every value in Magma belongs to a unique parent magma, the system provides a mechanism for automatic and forced coercion, to move a value from one magma to another. To take a simple example, when an integer is added to a rational, Magma automatically coerces the integer into the rational field, so that the addition operation can be carried out on two values with the same parent. Other situations require forced coercion, in which the user states the desired parent magma with the ! operator.

Example

Parents and categories:
> K := GF(7);
> P<x> := PolynomialRing(K);    
> print Category(K), Category(P);
FldFin RngUPol
> e := 5;
> print Parent(e), Category(e);
Integer Ring
RngIntElt

Forced coercion: > print Parent(K ! e); Finite field of size 7 > print Parent(P ! e); Univariate Polynomial Algebra in x over Finite field of size 7

Automatic coercion: > f := x^2 + e + 6; print f; x^2 + 4 > print Parent(f) eq P; true

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