Ask Your Question

retrieving word for free group with custom set of generators

asked 2020-03-06 23:36:47 +0100

grobber gravatar image

updated 2020-06-01 11:18:33 +0100

FrédéricC gravatar image

I would like to define a free group on a custom ordered list of symbols, like say

Frgp=Groups().free([f'a{j}' for j in range (5,10)])

i.e. a5 up to a9 (say). It's important that the list be defined programmatically as above, as the number of generators changes throughout the program run (their labels also need to change).

I would then like to recover elements of the group by evaluating at numbered lists, as in Frgp([1,2]) to get back a5*a6, say, as suggested in the docs. This syntax of Frgp(<numerical list>), however, only works when I define the group via one of the methods

Frgp.<x,y,z> = Groups().free()



which are not flexible enough to allow me to interpolate strings in variable names (or are they? I have tried all sorts of eval/exec trickery to no avail).

If I define the group in my preferred style (first code display above), then

sage: Frgp=Groups().free([f'a{j}' for j in range (5,10)])
sage: Frgp([1,2])

results in an error:

TypeError: 'sage.rings.integer.Integer' object is not iterable


To clarify, I am aware that the goal I alluded to above can be achieved by other means. For instance, I can do

sage: Frgp=Groups().free(5,'t')
sage: Frgp([1,2])([var(f'a{j}') for j in range (5,10)])

So in other words, I can create a list of symbolic variables and apply a free-group word to that. But this seems like a clumsy workaround. It would be preferable to work in the free group on the desired set of symbolic variables to begin with.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-03-07 08:30:56 +0100

grobber gravatar image

updated 2020-03-07 08:31:53 +0100

What ended up working: once I have the list of symbols, as in

sage: lst=tuple(f'a{j}' for j in range(5,10))

the free group can be constructed by passing the list via the key word argument names rather than directly:

sage: Frgp=Groups().free(names=lst)


sage: Frgp([1,2])

tuple() isn't crucial in the definition of lst: list() works just as well.

The point is there's a difference between Groups().free(names=lst) and Groups().free(lst) that I don't quite fully grok at the moment, but the former will do what I want whereas the latter wasn't:

sage: Groups().free([var('a')])
Free group indexed by {a}

sage: Groups().free(names=[var('a')])
Free Group on generators {a}

As you can see, sage reports slightly different output depending on whether the list is passed via names= or directly.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-03-06 23:36:47 +0100

Seen: 253 times

Last updated: Mar 07 '20