> < ^ Date: Tue, 28 Aug 2001 13:41:18 +0200 (MET DST)
> < ^ From: Willem de Graaf <degraaf@math.uu.nl >
> < ^ Subject: Re: infinite-dimensional vector spaces

Dear Jan,

Thank you for your question. You asked:

I'd like to work with finite-dimensional subspaces of a universal
enveloping algebra

This is possible in GAP. However, one needs to install some NiceVector
machinery. The code below does that. If you read it into GAP, then
it should be possible to work with finite-dimensional vector
spaces of elements of a universal enveloping algebra.

If you encounter further problems or questions, please ask.

Best wishes,

Willem de Graaf

#############################################################################
##
#F  IsSpaceOfUEAElements( <V> )
##
##  If <V> is a space of elements of a universal enveloping algebra,
##  then the `NiceFreeLeftModuleInfo' value of <V> is a record with the
##  following components.
##  \beginitems
##  `family' &
##     the elements family of <V>,
##
##  `monomials' &
##     a list of monomials occurring in the generators of <V>,
##
##
##  `zerocoeff' &
##     the zero coefficient of elements in <V>,
##
##  `zerovector' &
##     the zero row vector in the nice free left module,
##
##  `characteristic' &
##     the characteristic of the ground field.
##  \enditems
##  The `NiceVector' value of $v \in <V>$ is defined as the row vector of
##  coefficients of $v$ w.r.t. the list `monomials'.
##
##
DeclareHandlingByNiceBasis( "IsSpaceOfUEAElements",
    "for free left modules of elements of a universal enveloping algebra" );


#############################################################################
##
#M  NiceFreeLeftModuleInfo( <V> )
#M  NiceVector( <V>, <v> )
#M  UglyVector( <V>, <r> )
##
InstallHandlingByNiceBasis( "IsSpaceOfUEAElements", rec(
    detect := function( F, gens, V, zero )
      return IsElementOfFpAlgebraCollection( V );
      end,
NiceFreeLeftModuleInfo := function( V )
  local gens,
        monomials,
        gen,
        list,
        zero,
        info;

gens:= GeneratorsOfLeftModule( V );

monomials:= [];

for gen in gens do
  list:= ExtRepOfObj( gen )[2];
  UniteSet( monomials, list{ [ 1, 3 .. Length( list ) - 1 ] } );
od;

zero:= Zero( LeftActingDomain( V ) );
info:= rec( monomials := monomials,
            zerocoeff := zero,
            characteristic:= Characteristic( LeftActingDomain( V ) ), 
            family    := ElementsFamily( FamilyObj( V ) ) );

# For the zero row vector, catch the case of empty `monomials' list.
if IsEmpty( monomials ) then
  info.zerovector := [ zero ];
else
  info.zerovector := ListWithIdenticalEntries( Length( monomials ),
                                               zero );
fi;

return info;
end,

NiceVector := function( V, v )
  local info, c, monomials, i, pos;
  info:= NiceFreeLeftModuleInfo( V );
  c:= ShallowCopy( info.zerovector );
  v:= ExtRepOfObj( v )[2];
  monomials:= info.monomials;
  for i in [ 2, 4 .. Length( v ) ] do
    pos:= Position( monomials, v[ i-1 ] );
    if pos = fail then
      return fail;
    fi;
    c[ pos ]:= v[i];
  od;
  return c;
  end,

UglyVector := function( V, r )
  local info, list, i;
  info:= NiceFreeLeftModuleInfo( V );
  if Length( r ) <> Length( info.zerovector ) then
    return fail;
  elif IsEmpty( info.monomials ) then
    if IsZero( r ) then
      return Zero( V );
    else
      return fail;
    fi;
  fi;
  list:= [];
  for i in [ 1 .. Length( r ) ] do
    if r[i] <> info.zerocoeff then
      Add( list, info.monomials[i] );
      Add( list, r[i] );
    fi;
  od;
  return ObjByExtRep( info.family, [ info.characteristic, list ] );
  end ) );

> < [top]