---
title: "Generic Element Functions"
canonical: "https://docs.magma-maths.org/v2.30-1/BasicRings/IntroductionToRings/element.html"
source: "https://docs.magma-maths.org/v2.30-1/BasicRings/IntroductionToRings/element.md"
part: "Basic Rings"
chapter: "Introduction to Rings"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Basic Rings", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/index-basic-rings.md"}
  - {"title": "Introduction to Rings", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/IntroductionToRings/index-introduction-to-rings.md"}
prev: {"title": "Generic Ring Functions", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/IntroductionToRings/generic.md"}
next: {"title": "Ideals and Quotient Rings", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/IntroductionToRings/ideal-quotient.md"}
intrinsics:
  - {"name": "Parent", "signature": "Parent(r): RngElt -> Rng"}
  - {"name": "Category", "signature": "Category(r): RngElt -> Cat"}
  - {"name": "Type", "signature": "Type(r): RngElt -> Cat"}
  - {"name": "Zero", "signature": "Zero(R): Rng -> RngElt"}
  - {"name": "One", "signature": "One(R): Rng -> RngElt"}
  - {"name": "Id", "signature": "Id(R): Rng -> RngElt"}
  - {"name": "!", "signature": "R ! a: Rng, RngElt -> RngElt"}
  - {"name": "Random", "signature": "Random(R): Rng -> RngElt"}
  - {"name": "Representative", "signature": "Representative(R): Rng -> RngElt"}
  - {"name": "Rep", "signature": "Rep(R): Rng -> RngElt"}
  - {"name": "+", "signature": "+ a: RngElt -> RngElt"}
  - {"name": "-", "signature": "- a: RngElt -> RngElt"}
  - {"name": "+", "signature": "a + b: RngElt, RngElt -> RngElt"}
  - {"name": "-", "signature": "a - b: RngElt, RngElt -> RngElt"}
  - {"name": "*", "signature": "a * b: RngElt, RngElt -> RngElt"}
  - {"name": "^", "signature": "a ^ k: RngElt, RngIntElt -> RngElt"}
  - {"name": "/", "signature": "a / b: RngElt, RngElt -> RngElt"}
  - {"name": "+:=", "signature": "a +:= b: RngElt, RngElt -> RngElt"}
  - {"name": "-:=", "signature": "a -:= b: RngElt, RngElt -> RngElt"}
  - {"name": "*:=", "signature": "a *:= b: RngElt, RngElt -> RngElt"}
  - {"name": "/:=", "signature": "a /:= b: RngElt, RngElt -> RngElt"}
  - {"name": "^:=", "signature": "a ^:= k: RngElt, RngIntElt -> RngElt"}
  - {"name": "eq", "signature": "a eq b: RngElt, RngElt -> BoolElt"}
  - {"name": "ne", "signature": "a ne b: RngElt, RngElt -> BoolElt"}
  - {"name": "eq", "signature": "R eq S: Rng, Rng -> BoolElt"}
  - {"name": "ne", "signature": "R ne S: Rng, Rng -> BoolElt"}
  - {"name": "in", "signature": "a in R: RngElt, Rng -> BoolElt"}
  - {"name": "notin", "signature": "a notin R: RngElt, Rng -> BoolElt"}
  - {"name": "IsZero", "signature": "IsZero(a): RngElt -> BoolElt"}
  - {"name": "IsOne", "signature": "IsOne(a): RngElt -> BoolElt"}
  - {"name": "IsMinusOne", "signature": "IsMinusOne(a): RngElt -> BoolElt"}
  - {"name": "IsUnit", "signature": "IsUnit(a): RngElt -> BoolElt"}
  - {"name": "IsIdempotent", "signature": "IsIdempotent(x): RngElt -> BoolElt"}
  - {"name": "IsNilpotent", "signature": "IsNilpotent(x): RngElt -> BoolElt"}
  - {"name": "IsZeroDivisor", "signature": "IsZeroDivisor(x): RngElt -> BoolElt"}
  - {"name": "IsIrreducible", "signature": "IsIrreducible(x): RngElt -> BoolElt"}
  - {"name": "IsPrime", "signature": "IsPrime(x): RngElt -> BoolElt"}
  - {"name": "gt", "signature": "a gt b: RngElt, RngElt -> BoolElt"}
  - {"name": "ge", "signature": "a ge b: RngElt, RngElt -> BoolElt"}
  - {"name": "lt", "signature": "a lt b: RngElt, RngElt -> BoolElt"}
  - {"name": "le", "signature": "a le b: RngElt, RngElt -> BoolElt"}
  - {"name": "Maximum", "signature": "Maximum(a, b): RngElt, RngElt -> RngElt"}
  - {"name": "Maximum", "signature": "Maximum(Q): [RngIntElt] -> RngElt"}
  - {"name": "Minimum", "signature": "Minimum(a, b): RngElt, RngElt -> RngElt"}
  - {"name": "Minimum", "signature": "Minimum(Q): [RngIntElt] -> RngElt"}
---

<a id="element"></a>
<a id="rngintro-elt-funcs"></a>
# Generic Element Functions

## Parent and Category

<a id="function-parent-rngelt"></a>
### `Parent(r): RngElt -> Rng`

The (default) parent ring of ring element $r$. Usually the parent of $r$ has been created explicitly before, but in certain cases, such as literal integers, rationals, reals, and values returned by certain functions a default parent is created in the background.

<a id="function-category-rngelt"></a>
### `Category(r): RngElt -> Cat`

<a id="function-type-rngelt"></a>
### `Type(r): RngElt -> Cat`

The ‘type’ of $r$, that is, the Magma category to which the ring element $r$ belongs. The procedure call `ListCategories()` gives a list of all the categories, as does the Appendix.

## Creation of Elements

<a id="function-zero-rng"></a>
### `Zero(R): Rng -> RngElt`

The zero element of ring $R$; this is equivalent to `R ! 0`.

<a id="function-one-rng"></a>
### `One(R): Rng -> RngElt`

<a id="function-id-rng"></a>
### `Id(R): Rng -> RngElt`

The multiplicative identity $1$ of ring $R$; this is equivalent to `R ! 1`.

<a id="operation-op-rng-rngelt"></a>
### `R ! a: Rng, RngElt -> RngElt`

Coerce the element $a$ of some ring into the ring $R$. (The rules on coercion are explained earlier in this Chapter.) If $a$ is an integer, the coercion will always succeed: the element $a\cdot 1_R$ will be returned, where $1_R$ is the unit element of $R$.

<a id="function-random-rng"></a>
### `Random(R): Rng -> RngElt`

A random element of the finite ring $R$ (every element of $R$ has the same probability of being returned).

<a id="function-representative-rng"></a>
### `Representative(R): Rng -> RngElt`

<a id="function-rep-rng"></a>
### `Rep(R): Rng -> RngElt`

A representative element of the finite ring $R$.

## Arithmetic Operations

<a id="operation-operation-rngelt-rngelt"></a>
### `+ a: RngElt -> RngElt`

Element $a$.

<a id="operation-operation-rngelt-rngelt-2"></a>
### `- a: RngElt -> RngElt`

The negation (additive inverse) of element $a$.

<a id="operation-op-plus-rngelt-rngelt"></a>
### `a + b: RngElt, RngElt -> RngElt`

The sum of the ring elements $a$ and $b$; if $a$ and $b$ do not belong to the same ring $R$, an attempt will be made to find a common overstructure in which the sum can be taken.

<a id="operation-op-minus-rngelt-rngelt"></a>
### `a - b: RngElt, RngElt -> RngElt`

The difference of the ring elements $a$ and $b$; if $a$ and $b$ do not belong to the same ring $R$, an attempt will be made to find a common overstructure in which the difference can be taken.

<a id="operation-op-times-rngelt-rngelt"></a>
### `a * b: RngElt, RngElt -> RngElt`

The product of the ring elements $a$ and $b$; if $a$ and $b$ do not belong to the same ring $R$, an attempt will be made to find a common overstructure in which the product can be taken.

<a id="operation-op-pow-rngelt-rngintelt"></a>
### `a ^ k: RngElt, RngIntElt -> RngElt`

Form the $k$-th power of the ring element $a$, for small $k$. If $k = 0$, then $a^k$ returns $1$, even when $a = 0$. If $k$ is negative, $a$ must have a multiplicative inverse and the result is $(a^{-1})^{-k}$.

<a id="operation-op-div-rngelt-rngelt"></a>
### `a / b: RngElt, RngElt -> RngElt`

Given an element $a$ of $R$ and a unit $b$ of $R$, form the quotient of the elements $a$ and $b$. If $b$ is not invertible in $R$, an error results, unless both $a$ and $b$ are integers, in which case `a / b` returns the rational number $a/b$. If $a$ and $b$ do not belong to the same ring $R$, an attempt will be made to find a common overstructure in which the quotient can be taken.

<a id="operation-operation-rngelt-rngelt-rngelt"></a>
### `a +:= b: RngElt, RngElt -> RngElt`

Mutation assignment: change $a$ into the sum of $a$ and $b$.

<a id="operation-operation-rngelt-rngelt-rngelt-2"></a>
### `a -:= b: RngElt, RngElt -> RngElt`

Mutation assignment: change $a$ into the difference of $a$ and $b$.

<a id="operation-operation-rngelt-rngelt-rngelt-3"></a>
### `a *:= b: RngElt, RngElt -> RngElt`

Mutation assignment: change $a$ into the product of $a$ and $b$.

<a id="operation-operation-rngelt-rngelt-rngelt-4"></a>
### `a /:= b: RngElt, RngElt -> RngElt`

Mutation assignment: change $a$ into the quotient of $a$ and $b$.

<a id="operation-operation-rngelt-rngintelt-rngelt"></a>
### `a ^:= k: RngElt, RngIntElt -> RngElt`

Mutation assignment: change $a$ into the power $a^k$.

## Equality and Membership

<a id="operation-op-eq-rngelt-rngelt"></a>
### `a eq b: RngElt, RngElt -> BoolElt`

Returns `true` if the elements $a$ and $b$ of $R$ are the same, otherwise `false`.

<a id="operation-op-ne-rngelt-rngelt"></a>
### `a ne b: RngElt, RngElt -> BoolElt`

Returns `true` if the elements $a$ and $b$ of $R$ are distinct, otherwise `false`.

<a id="operation-op-eq-rng-rng-2"></a>
### `R eq S: Rng, Rng -> BoolElt`

Returns `true` if the rings $R$ and $S$ are the same, otherwise `false`.

<a id="operation-op-ne-rng-rng-2"></a>
### `R ne S: Rng, Rng -> BoolElt`

Returns `true` if the rings $R$ and $S$ are distinct, otherwise `false`.

<a id="operation-op-in-rngelt-rng"></a>
### `a in R: RngElt, Rng -> BoolElt`

Returns `true` if and only if $a$ is an element of $R$.

<a id="operation-op-notin-rngelt-rng"></a>
### `a notin R: RngElt, Rng -> BoolElt`

Returns `true` if and only if $a$ is not an element of $R$.

## Predicates on Ring Elements

<a id="function-iszero-rngelt"></a>
### `IsZero(a): RngElt -> BoolElt`

Returns `true` if and only if the element $a$ of $R$ equals $0_R$.

<a id="function-isone-rngelt"></a>
### `IsOne(a): RngElt -> BoolElt`

Returns `true` if and only if the element $a$ of $R$ equals $1_R$.

<a id="function-isminusone-rngelt"></a>
### `IsMinusOne(a): RngElt -> BoolElt`

Returns `true` if and only if the element $a$ of $R$ equals the element $-1$ of $R$.

<a id="function-isunit-rngelt"></a>
### `IsUnit(a): RngElt -> BoolElt`

Returns `true` if $a$ is a unit in its parent $R$, `false` otherwise.

<a id="function-isidempotent-rngelt"></a>
### `IsIdempotent(x): RngElt -> BoolElt`

Returns `true` if and only if $x^2$ equals $x$.

<a id="function-isnilpotent-rngelt"></a>
### `IsNilpotent(x): RngElt -> BoolElt`

Returns `true` if and only if some integer power $x^i$ of $x$ is zero.

<a id="function-iszerodivisor-rngelt"></a>
### `IsZeroDivisor(x): RngElt -> BoolElt`

Returns `true` if and only if $x$ is a zero-divisor, that is, there exists an element $y$ in the parent $R$ of $x$ such that $xy=0$.

<a id="function-isirreducible-rngelt"></a>
### `IsIrreducible(x): RngElt -> BoolElt`

Returns `true` if and only if the parent $R$ of the element $x$ is a domain and $x$ is irreducible in $R$, that is, $x$ is a non-unit of $R$ and whenever a product $ab$ of elements of $R$ divides $x$ then $a$ or $b$ is a unit of $R$.

<a id="function-isprime-rngelt"></a>
### `IsPrime(x): RngElt -> BoolElt`

Returns `true` if and only if the parent $R$ of the element $x$ is a domain and $x$ is a prime element of $R$, that is, $x$ is neither $0$ nor a unit and whenever $x$ divides the product $ab$ of two elements of $R$ it divides $a$ or $b$.

## Comparison of Ring Elements

The comparison operations are only defined on types of ring that are ordered.

<a id="operation-op-gt-rngelt-rngelt"></a>
### `a gt b: RngElt, RngElt -> BoolElt`

Returns `true` if the ring element $a$ is greater than the ring element $b$, otherwise `false`.

<a id="operation-op-ge-rngelt-rngelt"></a>
### `a ge b: RngElt, RngElt -> BoolElt`

Returns `true` if the ring element $a$ is greater than or equal to the ring element $b$, otherwise `false`.

<a id="operation-op-lt-rngelt-rngelt"></a>
### `a lt b: RngElt, RngElt -> BoolElt`

Returns `true` if the ring element $a$ is less than the ring element $b$, otherwise `false`.

<a id="operation-op-le-rngelt-rngelt"></a>
### `a le b: RngElt, RngElt -> BoolElt`

Returns `true` if the ring element $a$ is less than or equal to the ring element $b$, otherwise `false`.

<a id="function-maximum-rngelt-rngelt"></a>
### `Maximum(a, b): RngElt, RngElt -> RngElt`

The maximum of the ring elements $a$ and $b$; if $a$ and $b$ do not belong to the same ring $R$, an attempt will be made to find a common overstructure in which the maximum can be taken.

<a id="function-maximum-rngintelt"></a>
### `Maximum(Q): [RngIntElt] -> RngElt`

The maximum of the sequence $Q$ of ring elements.

<a id="function-minimum-rngelt-rngelt"></a>
### `Minimum(a, b): RngElt, RngElt -> RngElt`

The minimum of the ring elements $a$ and $b$; if $a$ and $b$ do not belong to the same ring $R$, an attempt will be made to find a common overstructure in which the minimum can be taken.

<a id="function-minimum-rngintelt"></a>
### `Minimum(Q): [RngIntElt] -> RngElt`

The minimum of the sequence $Q$ of ring elements.
