Vector as function from a finite set

asked 2024-01-11 10:19:49 +0200

Hi, I want to represent a vector as a function from a finite set (where its size is the dimension) instead of a list(the application is semantics of linear logic). So for example, a one dimensional vector over a a finite field of size 3 would be implemented as this:
One = Set(['ball'])
Ex1 = GF(3) ^ One
instead of
Ex 2 = GF(3) ^ 1.
Unfortunately. Sagemath considers Ex2 as a vectorspace( Vector space of dimension 1 over Finite Field of size 3), but Ex1 is just a free module (Free module generated by {'ball'} over Finite Field of size 3). So for example the Hom function does not return vector space of linear transformations. But from a mathematical point of view, of course both Ex1 an Ex2 are vector spaces.

How to get around this? I need to retain the structure of the finite set that indexes the vector. My intuition (that comes from programming) is that I need to implement some kind of datatype which when used in operations that requires a vector returns a representation as a list and uses the size of the index set when creating the vector space. But perhaps there is already support for this. Please suggest a Sagemath native way to implement this. Pointers to already implemented code that does something similar would be great!

edit retag flag offensive close merge delete



What you are planing to do with these objects? Can you provide a small example with the expected outcome?

Max Alekseyev gravatar imageMax Alekseyev ( 2024-01-11 16:54:01 +0200 )edit

Something like that ?

sage: M=CombinatorialFreeModule(ZZ,["a", "poire", "🍎"])
sage: M
Free module generated by {'a', 'poire', '🍎'} over Integer Ring
sage: a,b,c=M.gens()
sage: 3*a+c
3*B['a'] + B['🍎']
sage: unicode_art(_)
3*B  + B 
   a    🍎
FrédéricC gravatar imageFrédéricC ( 2024-01-16 09:34:58 +0200 )edit