Overview - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Ordinals

A package for ordinal numbers and their arithmetic

 Calling Sequence Ordinals:-command(arguments) command(arguments)

Description

 • The Ordinals package is a collection of commands for computing with ordinal numbers in Cantor normal form. Mathematically, an ordinal number, or ordinal for short, represents an isomorphism class of well-orderings. The Ordinals package can represent and handle all ordinals less than ${\mathrm{ϵ}}_{0}$, that is, ordinal numbers that can be obtained from non-negative integers and $\mathbf{\omega }$, the ordinal for the standard ordering of the natural numbers $ℕ$, in a finite number of steps by ordinal addition, multiplication and exponentiation.
 • Every non-negative integer $n$ is an ordinal, representing the finite well-ordered set $\left\{0<1<\cdots  of numbers less than $n$. Infinite ordinals can be created using the Ordinal constructor. The constant omega represents the ordinal $\mathbf{\omega }$.
 • The ordinals themselves are well-ordered by the relation $a\preccurlyeq b$ meaning that the well-ordering represented by $a$ is order-isomorphic to an initial segment of the well-ordering represented by $b$. See LessThan for more details.
 • The data structure for an infinite ordinal is basically a list of pairs $\left[\left[{e}_{1},{c}_{1}\right],\mathrm{...},\left[{e}_{k},{c}_{k}\right]\right]$ encoding its Cantor normal form ${\mathbf{\omega }}^{{e}_{1}}\cdot {c}_{1}+\cdots +{\mathbf{\omega }}^{{e}_{k}}\cdot {c}_{k}$, where $k\ge 1$ is an integer, ${e}_{1}\succ \cdots \succ {e}_{k}$ are ordinals (that is, non-negative integers, or recursively, ordinal data structures) and ${c}_{1},\mathrm{...},{c}_{k}$ are positive integers. See Ordinal for more details.
 • The access functions degree, lcoeff and lterm return ${e}_{1}$, ${c}_{1}$ and $\left[{e}_{1},{c}_{1}\right]$, respectively. Similarly, the access functions tdegree, tcoeff and tterm return ${e}_{k}$, ${c}_{k}$ and $\left[{e}_{k},{c}_{k}\right]$, respectively.
 • The basic arithmetic operations for ordinals are addition, multiplication, and exponentiation. Their corresponding inverse operations are left subtraction, left division, and logarithm, respectively. Other operations implemented include maximum and minimum, greatest common left divisors and least common right multiples, and factorization.
 • The arithmetic operators +, ., ^ and the relational operators < and <= are overloaded for ordinals, and they cause the corresponding commands Add, Mult, Power and LessThan, respectively, to be executed. Note that + is not a commutative operator for ordinals. In addition, the package also recognizes inactive or inert versions of these operators, namely, &+, &., &^, &-, &<, &>, &<=, and &>=. Such inactive operators do not result in any computations and are useful for display purposes. The value command turns these inert operators into their active forms.
 • The Ordinals package allows ordinals to be parametric. This means that the coefficients ${c}_{1},\mathrm{...},{c}_{k}$ in the Cantor normal form may contain variables, such as $x$ or ${y}_{1}$, and depend on these polynomially with positive integer coefficients. For example, ${x}^{2}+2$ is a valid parametric coefficient, but ${x}^{2}-2$, $\sqrt{x}$, and $\mathrm{sin}\left(x\right)+\frac{1}{3}$ are not. Currently, only the coefficients ${c}_{i}$ can be parametric; the exponents ${e}_{i}$ cannot contain any parameters.
 • All parameters are implicitly assumed to represent non-negative integers. Each command in the Ordinals package guarantees that the results it returns are correct when arbitrary non-negative integers are substituted for some or all of the parameters. If such a universally valid result cannot be computed, an error will be raised. For example, if $x$ is a parameter, then ${\left(x+2\right)}^{\mathbf{\omega }}=\mathbf{\omega }$ is correct for all non-negative integer values of $x$, but neither ${x}^{\mathbf{\omega }}=\mathbf{\omega }$ nor ${\left(x+1\right)}^{\mathbf{\omega }}=\mathbf{\omega }$ are universally valid, since ${0}^{\mathbf{\omega }}=0$ and ${1}^{\mathbf{\omega }}=1$.
 • The Eval command can be used to substitute integer values or polynomial expressions for some or all of the parameters in a parametric ordinal.

Accessing Ordinals Package Commands

 • Each command in the Ordinals package can be accessed by using either the long form or the short form of the command name in the command calling sequence.
 The long form, Ordinals:-command, is always available. The short form can be used after loading the package.

List of Ordinals Package Commands

 • The following is a list of commands available in the Ordinals package.

 • To display the help page for a particular Ordinals command, see Getting Help with a Command in a Package.

Examples

 > $\mathrm{with}\left(\mathrm{Ordinals}\right)$
 $\left[{\mathrm{+}}{,}{\mathrm{.}}{,}{\mathrm{<}}{,}{\mathrm{<=}}{,}{\mathrm{Add}}{,}{\mathrm{Base}}{,}{\mathrm{Dec}}{,}{\mathrm{Decompose}}{,}{\mathrm{Div}}{,}{\mathrm{Eval}}{,}{\mathrm{Factor}}{,}{\mathrm{Gcd}}{,}{\mathrm{Lcm}}{,}{\mathrm{LessThan}}{,}{\mathrm{Log}}{,}{\mathrm{Max}}{,}{\mathrm{Min}}{,}{\mathrm{Mult}}{,}{\mathrm{Ordinal}}{,}{\mathrm{Power}}{,}{\mathrm{Split}}{,}{\mathrm{Sub}}{,}{\mathrm{^}}{,}{\mathrm{degree}}{,}{\mathrm{lcoeff}}{,}{\mathrm{log}}{,}{\mathrm{lterm}}{,}{\mathrm{\omega }}{,}{\mathrm{quo}}{,}{\mathrm{rem}}{,}{\mathrm{tcoeff}}{,}{\mathrm{tdegree}}{,}{\mathrm{tterm}}\right]$ (1)

Creating ordinals.

 > $a≔2$
 ${a}{≔}{2}$ (2)
 > $b≔\mathrm{ω}$
 ${b}{≔}{\mathbf{\omega }}$ (3)
 > $c≔\mathrm{Ordinal}\left(\left[\left[\mathrm{ω},1\right],\left[2,3\right],\left[0,5\right]\right]\right)$
 ${c}{≔}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (4)
 > $\mathrm{type}\left(a,\mathrm{ordinal}\right),\mathrm{type}\left(b,\mathrm{ordinal}\right),\mathrm{type}\left(c,\mathrm{ordinal}\right)$
 ${\mathrm{false}}{,}{\mathrm{true}}{,}{\mathrm{true}}$ (5)

Extracting components.

 > $\mathrm{degree}\left(a\right),\mathrm{degree}\left(b\right),\mathrm{degree}\left(c\right)$
 ${0}{,}{1}{,}{\mathbf{\omega }}$ (6)
 > $\mathrm{lcoeff}\left(a\right),\mathrm{lcoeff}\left(b\right),\mathrm{lcoeff}\left(c\right)$
 ${2}{,}{1}{,}{1}$ (7)
 > $\mathrm{tterm}\left(a\right),\mathrm{tterm}\left(b\right),\mathrm{tterm}\left(c\right)$
 $\left[{0}{,}{2}\right]{,}\left[{1}{,}{1}\right]{,}\left[{0}{,}{5}\right]$ (8)

 > $\mathrm{Add}\left(c,a\right)=c+a$
 ${{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{7}{=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{7}$ (9)

Using inert operators for display. The inert addition operator &+ is rendered as a regular + but in grey. Also note that addition is non-commutative.

 > $a&+c=a+c$
 ${2}{\mathbf{+}}\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (10)

Adding more than two ordinals.

 > $d≔a+c+b$
 ${d}{≔}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{\mathbf{\omega }}$ (11)

Comparing and subtracting ordinals.

 > $\mathrm{LessThan}\left(c,d\right),c
 ${\mathrm{true}}{,}{\mathrm{true}}$ (12)
 > $d&-c=\mathrm{Sub}\left(d,c\right)$
 $\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{\mathbf{\omega }}\right){\mathbf{-}}\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){=}{\mathbf{\omega }}$ (13)

Verify the result.

 > $c&+\mathrm{ω}=c+\mathrm{ω}$
 $\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){\mathbf{+}}{\mathbf{\omega }}{=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{\mathbf{\omega }}$ (14)

Multiplication and exponentiation.

 > $\mathrm{Mult}\left(b,c\right)=\mathrm{.}\left(b,c\right)$
 ${{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{3}}{\cdot }{3}{+}{\mathbf{\omega }}{\cdot }{5}{=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{3}}{\cdot }{3}{+}{\mathbf{\omega }}{\cdot }{5}$ (15)
 > $c&.b=\mathrm{.}\left(c,b\right)$
 $\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){\mathbf{\cdot }}{\mathbf{\omega }}{=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}{+}{1}}$ (16)
 > $\left(c&.b\right)&.a=\mathrm{.}\left(c,b,a\right)$
 $\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){\mathbf{\cdot }}{\mathbf{\omega }}{\mathbf{\cdot }}{2}{=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}{+}{1}}{\cdot }{2}$ (17)
 > $\mathrm{Power}\left(c,a\right)={c}^{a}$
 ${{\mathbf{\omega }}}^{{\mathbf{\omega }}{\cdot }{2}}{+}{{\mathbf{\omega }}}^{{\mathbf{\omega }}{+}{2}}{\cdot }{3}{+}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{\cdot }{5}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}{=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}{\cdot }{2}}{+}{{\mathbf{\omega }}}^{{\mathbf{\omega }}{+}{2}}{\cdot }{3}{+}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{\cdot }{5}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (18)
 > $a&^c={a}^{c}$
 ${\left({2}\right)}^{{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}}{=}{{\mathbf{\omega }}}^{{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{\mathbf{\omega }}{\cdot }{3}}{\cdot }{32}$ (19)

Division, greatest common divisors.

 > $e≔\mathrm{Ordinal}\left(\left[\left[4,2\right],\left[3,1\right],\left[2,3\right],\left[0,5\right]\right]\right)$
 ${e}{≔}{{\mathbf{\omega }}}^{{4}}{\cdot }{2}{+}{{\mathbf{\omega }}}^{{3}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (20)
 > $g≔\mathrm{Gcd}\left(c,e\right)$
 ${g}{≔}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (21)
 > $\mathrm{c1}≔\mathrm{quo}\left(c,g\right)$
 ${\mathrm{c1}}{≔}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{1}$ (22)
 > $\mathrm{e1}≔\mathrm{quo}\left(e,g\right)$
 ${\mathrm{e1}}{≔}{{\mathbf{\omega }}}^{{2}}{\cdot }{2}{+}{\mathbf{\omega }}{+}{1}$ (23)

Verify the divisibility.

 > $\mathrm{rem}\left(c,g\right),\mathrm{rem}\left(e,g\right)$
 ${0}{,}{0}$ (24)
 > $g&.\mathrm{c1}=\mathrm{.}\left(g,\mathrm{c1}\right)$
 $\left({{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){\mathbf{\cdot }}\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{1}\right){=}{{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (25)
 > $g&.\mathrm{e1}=\mathrm{.}\left(g,\mathrm{e1}\right)$
 $\left({{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}\right){\mathbf{\cdot }}\left({{\mathbf{\omega }}}^{{2}}{\cdot }{2}{+}{\mathbf{\omega }}{+}{1}\right){=}{{\mathbf{\omega }}}^{{4}}{\cdot }{2}{+}{{\mathbf{\omega }}}^{{3}}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (26)

Verify the gcd property by factorization.

 > $\mathrm{Factor}\left(c,\mathrm{output}=\mathrm{inert}\right)$
 ${5}{\mathbf{\cdot }}\left({{\mathbf{\omega }}}^{{2}}{+}{1}\right){\mathbf{\cdot }}{3}{\mathbf{\cdot }}\left({{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{1}\right)$ (27)
 > $\mathrm{Factor}\left(e,\mathrm{output}=\mathrm{inert}\right)$
 ${5}{\mathbf{\cdot }}\left({{\mathbf{\omega }}}^{{2}}{+}{1}\right){\mathbf{\cdot }}{3}{\mathbf{\cdot }}{\left({\mathbf{\omega }}{+}{1}\right)}^{{2}}{\mathbf{\cdot }}{2}$ (28)
 > $\mathrm{Factor}\left(g,\mathrm{output}=\mathrm{inert}\right)$
 ${5}{\mathbf{\cdot }}\left({{\mathbf{\omega }}}^{{2}}{+}{1}\right){\mathbf{\cdot }}{3}$ (29)
 > $\mathrm{value}\left(\right)$
 ${{\mathbf{\omega }}}^{{2}}{\cdot }{3}{+}{5}$ (30)
 > $\mathrm{Factor}\left(\mathrm{c1},\mathrm{output}=\mathrm{inert}\right)$
 ${{\mathbf{\omega }}}^{{\mathbf{\omega }}}{+}{1}$ (31)
 > $\mathrm{Factor}\left(\mathrm{e1},\mathrm{output}=\mathrm{inert}\right)$
 ${\left({\mathbf{\omega }}{+}{1}\right)}^{{2}}{\mathbf{\cdot }}{2}$ (32)
 > $\mathrm{Gcd}\left(\mathrm{c1},\mathrm{e1}\right)$
 ${1}$ (33)

Parametric ordinals. The variables $x,y,z$ below are parameters implicitly assumed to represent non-negative integers. Unless there is an error, the results below remain correct for arbitrary non-negative integer values of the parameters.

 > $r≔\left(\mathrm{ω}+x\right)&.\left(\mathrm{ω}+1\right):$
 > $r=\mathrm{value}\left(r\right)$
 $\left({\mathbf{\omega }}{+}{x}\right){\mathbf{\cdot }}\left({\mathbf{\omega }}{+}{1}\right){=}{{\mathbf{\omega }}}^{{2}}{+}{\mathbf{\omega }}{+}{x}$ (34)

Substitute a value for x.

 > $\mathrm{r1}≔\genfrac{}{}{0}{}{r}{\phantom{x=1000}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{|}\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{r}}{x=1000}:$
 > $\mathrm{r1}=\mathrm{value}\left(\mathrm{r1}\right)$
 $\left({\mathbf{\omega }}{+}{1000}\right){\mathbf{\cdot }}\left({\mathbf{\omega }}{+}{1}\right){=}{{\mathbf{\omega }}}^{{2}}{+}{\mathbf{\omega }}{+}{1000}$ (35)
 > $p≔\mathrm{.}\left({\mathrm{ω}}^{2},x+1\right)+\mathrm{.}\left(\mathrm{ω},y\right)+z$
 ${p}{≔}{{\mathbf{\omega }}}^{{2}}{\cdot }\left({x}{+}{1}\right){+}{\mathbf{\omega }}{\cdot }{y}{+}{z}$ (36)
 > ${p}^{3}$
 > ${\left(\genfrac{}{}{0}{}{p}{\phantom{z=z+1}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{|}\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{p}}{z=z+1}\right)}^{3}$
 ${{\mathbf{\omega }}}^{{6}}{\cdot }\left({x}{+}{1}\right){+}{{\mathbf{\omega }}}^{{5}}{\cdot }{y}{+}{{\mathbf{\omega }}}^{{4}}{\cdot }\left({x}{}{z}{+}{x}{+}{z}{+}{1}\right){+}{{\mathbf{\omega }}}^{{3}}{\cdot }{y}{+}{{\mathbf{\omega }}}^{{2}}{\cdot }\left({x}{}{z}{+}{x}{+}{z}{+}{1}\right){+}{\mathbf{\omega }}{\cdot }{y}{+}\left({z}{+}{1}\right)$ (37)

Indeed, the result when $z=0$ looks very different:

 > ${\left(\genfrac{}{}{0}{}{p}{\phantom{z=0}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{|}\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{p}}{z=0}\right)}^{3}$
 ${{\mathbf{\omega }}}^{{6}}{\cdot }\left({x}{+}{1}\right){+}{{\mathbf{\omega }}}^{{5}}{\cdot }{y}$ (38)

Compatibility

 • The Ordinals package was introduced in Maple 2015.
 • For more information on Maple 2015 changes, see Updates in Maple 2015.