Magma - Maple Programming Help

Home : Support : Online Help : Mathematics : Algebra : Magma : Magma/Enumerate

Magma

 Enumerate
 enumerate small finite magmas up to isomorphism

 Calling Sequence Enumerate( n ) Enumerate( n, options )

Parameters

 n - an integer greater than 1 options - optional property specifications

Options

 • Several options are provided to filter the kind of magmas enumerated.  For the most part, these circumscribe various equational identities that the enumerated magmas are required to satisfy.
 The recognized options are as follows:

 alternative enumerate alternative magmas anticommutative enumerate anti-commutative magmas associative enumerate associative magmas band enumerate bands (idempotent semigroups) commutative enumerate commutative magmas distributive enumerate distributive magmas group enumerate groups identity enumerate magmas in which 1 is the identity element idempotent enumerate idempotent magmas inverses enumerate magmas with identity in which elements are invertible kei enumerate kei (involutary quandles) leftbol enumerate left Bol magmas leftcancellative enumerate left cancellative magmas leftdistributive enumerate left distributive magmas leftinvolutary enumerate left involutary magmas (X(XY) = Y) leftsemimedial enumerate left semimedial magmas loop enumerate loops medial enumerate medial magmas monoid enumerate monoids quandle enumerate quandles quasigroup enumerate quasigroups rack enumerate racks rightbol enumerate right Bol magmas rightcancellative enumerate right cancellative magmas rightdistributive enumerate right distributive magmas rightinvolutary enumerate right involutary magmas (X(YY) = X) rightsemimedial enumerate right semimedial magmas semilattice enumerate semilattices (commutative and idempotent semigroups) squag enumerate squags (idempotent Steiner magmas) steiner enumerate Steiner magmas szasz enumerate Szasz (uniquely nonassociative) magmas zeropotent enumerate zeropotent magmas

 • The presence of multiple property options implies the conjunction of all the passed option properties.  Consequently, contradictory properties, such as associative and szasz will result in no magmas being enumerated.
 • process = processor
 The process = processor option allows you to specify a procedure to be called on each representative of the isomorphism classes of magmas enumerated. The procedure (processor) will be passed the Cayley table as the first argument and the order of the magma (a positive integer) as the second argument, and it can do whatever processing you want with the isomorphism class representative. Note that, if you want the processor argument to keep a copy of the Cayley table, then it must make an explicit copy (using, for instance, the copy command), since the same Array will be passed on each call, but with different numerical entries each time. The processor procedure should not attempt to modify the passed Array representing the Cayley table of the magma; changes will not be reflected in the enumeration.
 • test = tester
 The test = tester option allows you to specify a nonbuilt-in predicate to be used to prune the search tree. It is passed a partially completed Cayley table for a magma of the specified order, as well as the order.  Only nonzero elements of the Cayley table are to be tested, as zero elements are, at the time the supplied predicate is called, deemed to be undetermined. It will be called after all the built-in tests have been performed.  Therefore, it is safe to assume that partial Cayley tables passed to it already satisfy all partial checks implied by any other properties specified. The tester predicate you pass with this option will be called as a procedure with the partially completed Cayley table as the first argument, and the order of the magma (a positive integer) as the second argument.  The partially completed Cayley table has the form of a two-dimensional array with datatype equal to integer[4] and with C_order storage order.  Thus, it is possible to use a compiled procedure as the value of this option.

Description

 • The Enumerate command enumerates small (finite) magmas, optionally subject to certain constraints, described below. By default, it simply counts the number of such structures, up to isomorphism.
 When called with no options or optional arguments, the Enumerate command simply counts the number of isomorphism classes of magmas of order n.

Examples

 > $\mathrm{with}\left(\mathrm{Magma}\right):$

Count the number of two-element magmas, up to isomorphism

 > $\mathrm{Enumerate}\left(2\right)$
 ${10}$ (1)

Count the number of commutative and associative four-element magmas, up to isomorphism

 > $\mathrm{Enumerate}\left(4,'\mathrm{commutative}','\mathrm{associative}'\right)$
 ${58}$ (2)

Build a list of the three-element commutative and associative magmas.

 > $L≔\mathrm{Enumerate}\left(3,'\mathrm{associative}','\mathrm{commutative}','\mathrm{output}'='\mathrm{list}'\right)$
 ${L}{≔}\left[\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {1}& {1}\\ {1}& {1}& {1}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {1}& {1}\\ {1}& {1}& {2}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {1}& {1}\\ {1}& {1}& {3}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {1}& {2}\\ {1}& {2}& {3}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {2}& {1}\\ {1}& {1}& {3}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {2}& {2}\\ {1}& {2}& {2}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {2}& {2}\\ {1}& {2}& {3}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {1}\\ {1}& {2}& {3}\\ {1}& {3}& {2}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {3}\\ {1}& {1}& {3}\\ {3}& {3}& {1}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {1}& {3}\\ {1}& {2}& {3}\\ {3}& {3}& {1}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {2}& {2}\\ {2}& {1}& {1}\\ {2}& {1}& {1}\end{array}\right]{,}\left[\begin{array}{rrr}{1}& {2}& {3}\\ {2}& {3}& {1}\\ {3}& {1}& {2}\end{array}\right]\right]$ (3)
 > $\mathrm{andmap}\left(\mathrm{IsAssociative},L\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{andmap}\left(\mathrm{IsCommutative},L\right)$
 ${\mathrm{true}}$ (5)

Count, and print compactly, the groups of order 4.

 > $\mathrm{Enumerate}\left(4,'\mathrm{group}','\mathrm{process}'=\left(\left(m,n\right)→\mathrm{lprint}\left(\mathrm{convert}\left(m,'\mathrm{listlist}'\right)\right)\right)\right)$
 [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]] [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 2, 1], [4, 3, 1, 2]]
 ${2}$ (6)

Count the Moufang loops of order 6.

 > $L≔\mathrm{Enumerate}\left(6,\mathrm{leftbol},\mathrm{rightbol},\mathrm{loop}\right)$
 ${L}{≔}{2}$ (7)

Count connected quandles of order 5.

 > isconnected := proc( m, n )    local i, gens;    try      gens := map( convert, {seq}( convert( m[ .., i ], 'list' ), i = 1 .. n ), 'disjcyc' )    catch "not a permutation":      return true    end try;    evalb( nops( group:-orbit( permgroup( n, gens ), 1 ) ) = n ) end proc:
 > $\mathrm{Enumerate}\left(5,'\mathrm{quandle}','\mathrm{test}'=\mathrm{isconnected}\right)$
 ${3}$ (8)

Determine which groups of order 9 have the property that each member of the group is a square.  The passed procedures must ignore currently undefined entries (represented by zeros) in the table and return false just in the case that a duplicate diagonal entry is found.  Otherwise, true is returned to indicate to the enumeration engine that it should continue trying to complete the Cayley table.

 > Enumerate( 9, 'group', 'test' = proc( m, n )  local i, L := remove( type, [seq]( m[ i, i ], i = 1 .. n ), 0 );  evalb( nops( L ) = nops( {op}( L ) ) ) end proc );
 ${2}$ (9)

Count the loops of order 6 such that every square commutes with every member of the loop.  This illustrates the use of a procedure with the option autocompile.

 > sqcomm := proc( m :: Array( datatype = integer[4], order = C_order ), n :: posint )   option autocompile;   local i, j, z;   for i from 1 to n do     z := m[ i, i ];     if z <> 0 then # ignore undefined entries       for j from 1 to n do         if m[ z, j ] <> 0 and m[ j, z ] <> 0 then # ignore undefined entries           if m[ z, j ] <> m[ j, z ] then             return false           end if         end if       end do     end if   end do;   true end proc:
 > $L≔\mathrm{Enumerate}\left(6,'\mathrm{loop}','\mathrm{test}'='\mathrm{sqcomm}','\mathrm{output}'='\mathrm{list}'\right):$
 > $\mathrm{nops}\left(L\right)$
 ${15}$ (10)

How many of these are not commutative?

 > $\mathrm{nops}\left(\mathrm{remove}\left(\mathrm{IsCommutative},L\right)\right)$
 ${7}$ (11)

Compatibility

 • The Magma[Enumerate] command was introduced in Maple 15.