Lift some functions to magmas in general
This commit is contained in:
parent
cf2bc14423
commit
1ac424c524
@ -96,11 +96,12 @@ DeclareOperation( "NormalizedQuasigroupTable", [ IsMatrix ] );
|
||||
## CREATING QUASIGROUPS AND LOOPS MANUALLY
|
||||
## -------------------------------------------------------------------------
|
||||
|
||||
DeclareAttribute( "CayleyTable", IsQuasigroup );
|
||||
DeclareAttribute( "CayleyTable", IsMagma );
|
||||
DeclareOperation( "QuasigroupByCayleyTable", [ IsMatrix ] );
|
||||
DeclareOperation( "LoopByCayleyTable", [ IsMatrix ] );
|
||||
DeclareOperation( "SetQuasigroupElmName", [ IsQuasigroup, IsString ] );
|
||||
DeclareSynonym( "SetLoopElmName", SetQuasigroupElmName );
|
||||
DeclareAttribute( "ConstructorFromTable", IsMagma );
|
||||
DeclareOperation( "CanonicalCopy", [ IsMagma ] );
|
||||
|
||||
#############################################################################
|
||||
@ -142,9 +143,9 @@ DeclareOperation( "IntoGroup", [ IsMagma ] );
|
||||
## OPPOSITE QUASIGROUPS AND LOOPS
|
||||
## --------------------------------------------------------------------------
|
||||
|
||||
DeclareOperation( "OppositeQuasigroup", [ IsQuasigroup ] );
|
||||
DeclareOperation( "OppositeLoop", [ IsLoop ] );
|
||||
DeclareAttribute( "Opposite", IsQuasigroup );
|
||||
DeclareGlobalFunction( "OppositeQuasigroup");
|
||||
DeclareGlobalFunction( "OppositeLoop");
|
||||
DeclareAttribute( "Opposite", IsMagma );
|
||||
|
||||
#############################################################################
|
||||
## AUXILIARY
|
||||
|
@ -149,10 +149,12 @@ end );
|
||||
##
|
||||
#A CayleyTable( Q )
|
||||
##
|
||||
## Returns the Cayley table of the quasigroup <Q>
|
||||
## Returns the Cayley table of the magma <Q>. This is just like
|
||||
## its multiplication table, except in case Q is a submagma of P, in which
|
||||
## case the entries used are the indices in P rather than in Q.
|
||||
|
||||
InstallMethod( CayleyTable, "for quasigroup",
|
||||
[ IsQuasigroup ],
|
||||
InstallMethod( CayleyTable, "for magma",
|
||||
[ IsMagma ],
|
||||
function( Q )
|
||||
local elms, parent_elms;
|
||||
elms := Elements( Q );
|
||||
@ -194,6 +196,7 @@ function( ct )
|
||||
SetAsSSortedList( Q, elms );
|
||||
SetParent( Q, Q );
|
||||
SetCayleyTable( Q, ct );
|
||||
SetConstructorFromTable(QuasigroupByCayleyTable);
|
||||
return Q;
|
||||
end );
|
||||
|
||||
@ -232,6 +235,7 @@ function( ct )
|
||||
SetParent( L, L );
|
||||
SetCayleyTable( L, ct );
|
||||
SetOne( L, elms[ 1 ] );
|
||||
SetConstructorFromTable(LoopByCayleyTable);
|
||||
return L;
|
||||
end );
|
||||
|
||||
@ -249,22 +253,50 @@ function( Q, name )
|
||||
F!.names := name;
|
||||
end);
|
||||
|
||||
#############################################################################
|
||||
##
|
||||
#O ConstructorFromTable( M )
|
||||
##
|
||||
## Given a magma <M>, returns a function which will create a domain of the
|
||||
## same structure as M from from an operation table. This implementation of
|
||||
## the method is to backfill the constructors for library domains that do
|
||||
## not set the attribute directly at construction time. New domains that wish
|
||||
## to use facilities like CanonicalCopy or Opposite should call
|
||||
## SetConstructorFromTable at creation time.
|
||||
|
||||
InstallMethod( ConstructorFromTable, "for other magmas",
|
||||
[ IsMagma ],
|
||||
function ( M )
|
||||
# Go in reverse order of refinement of structure
|
||||
if IsGroup(M) then
|
||||
return GroupByMultiplicationTable;
|
||||
elif IsMagmaWithInverses(M) then
|
||||
return MagmaWithInversesByMultiplicationTable;
|
||||
elif IsMonoid(M) then
|
||||
return MonoidByMultiplicationTable;
|
||||
elif IsMagmaWithOne(M) then
|
||||
return MagmaWithOneByMultiplicationTable;
|
||||
elif IsSemigroup(M) then
|
||||
return SemigroupByMultiplicationTable;
|
||||
fi;
|
||||
return MagmaByMultiplicationTable;
|
||||
end);
|
||||
|
||||
|
||||
#############################################################################
|
||||
##
|
||||
#O CanonicalCopy( Q )
|
||||
##
|
||||
## Returns a canonical copy of <Q>, that is, an isomorphic object <O> with
|
||||
## canonical multiplication table and Parent( <O> ) = <O>.
|
||||
## canonical multiplication table and no parent set. Note that this is
|
||||
## guaranteed to be a new object, not satisfying IsIdenticalObj with any
|
||||
## previously existing structure. THEREFORE:
|
||||
## (PROG) Properties and attributes are lost!
|
||||
|
||||
InstallMethod( CanonicalCopy, "for quasigroup or loop",
|
||||
[ IsQuasigroup ],
|
||||
function( Q )
|
||||
if IsLoop( Q ) then
|
||||
return LoopByCayleyTable( CayleyTable( Q ) );
|
||||
fi;
|
||||
return QuasigroupByCayleyTable( CayleyTable( Q ) );
|
||||
end);
|
||||
InstallMethod( CanonicalCopy, "for magma",
|
||||
[ IsMagma ],
|
||||
M -> ConstructorFromTable(M)(MultiplicationTable(M));
|
||||
);
|
||||
|
||||
|
||||
#############################################################################
|
||||
@ -768,41 +800,31 @@ function( list, dummy )
|
||||
##
|
||||
#O OppositeQuasigroup( Q )
|
||||
##
|
||||
## Returns the quasigroup opposite to the quasigroup <Q>.
|
||||
## Identical to Opposite, except forces its return to be a quasigroup if
|
||||
## possible
|
||||
|
||||
InstallMethod( OppositeQuasigroup, "for quasigroup",
|
||||
[ IsQuasigroup ],
|
||||
function( Q )
|
||||
return QuasigroupByCayleyTable( TransposedMat( CayleyTable( Q ) ) );
|
||||
end );
|
||||
InstallGlobalFunction( OppositeQuasigroup,
|
||||
Q -> IntoQuasigroup( Opposite( L ) ) );
|
||||
|
||||
#############################################################################
|
||||
##
|
||||
#O OppositeLoop( Q )
|
||||
##
|
||||
## Returns the loop opposite to the loop <Q>.
|
||||
## Identical to Opposite, except forces its return to be a loop if possible
|
||||
|
||||
InstallMethod( OppositeLoop, "for loop",
|
||||
[ IsLoop ],
|
||||
function( Q )
|
||||
return LoopByCayleyTable( TransposedMat( CayleyTable( Q ) ) );
|
||||
end );
|
||||
InstallGlobalFunction( OppositeLoop, L -> IntoLoop( Opposite( L ) ) );
|
||||
|
||||
#############################################################################
|
||||
##
|
||||
#A Opposite( Q )
|
||||
#A Opposite( M )
|
||||
##
|
||||
## Returns the quasigroup opposite to the quasigroup <Q>. When
|
||||
## <Q> is a loop, a loop is returned.
|
||||
## Returns the magma opposite to the magma <M>, with as much structure
|
||||
## as can be preserved.
|
||||
|
||||
InstallMethod( Opposite, "for quasigroup",
|
||||
[ IsQuasigroup ],
|
||||
function( Q )
|
||||
if IsLoop( Q ) then
|
||||
return LoopByCayleyTable( TransposedMat( CayleyTable( Q ) ) );
|
||||
fi;
|
||||
return QuasigroupByCayleyTable( TransposedMat( CayleyTable( Q ) ) );
|
||||
end );
|
||||
InstallMethod( Opposite, "for magma",
|
||||
[ IsMagma ],
|
||||
M -> ConstructorFromTable(M)( TransposedMat( MultiplicationTable( M ) ) )
|
||||
);
|
||||
|
||||
#############################################################################
|
||||
## DISPLAYING QUASIGROUPS AND LOOPS
|
||||
|
Loading…
Reference in New Issue
Block a user