Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicer syntax for entering permutations #1189

Closed
fingolfin opened this issue Mar 21, 2022 · 4 comments · Fixed by #1307
Closed

Nicer syntax for entering permutations #1189

fingolfin opened this issue Mar 21, 2022 · 4 comments · Fixed by #1307
Labels
enhancement New feature or request topic: groups

Comments

@fingolfin
Copy link
Member

Right now, you may see something like this in a REPL or notebook:

julia> G
<permutation group of size 645120 with 9 generators>

julia> gens(G)
9-element Vector{PermGroupElem}:
 (1,10)
 (2,11)
 (3,12)
 (4,13)
 (5,14)
 (6,8)
 (7,9)
 (1,2,3,4,5,6,7)(8,9,10,11,12,13,14)
 (1,2)(10,11)

But how can you enter this group again, given just this output?

One idea would be to write a macro which can take a single permutation or a list and turn them into OSCAR permutation (we already had a similar idea for GAP.jl, see See also oscar-system/GAP.jl#420)

So then you could perhaps write

gens = @perm 14 [
  (1,10)
 (2,11)
 (3,12)
 (4,13)
 (5,14)
 (6,8)
 (7,9)
 (1,2,3,4,5,6,7)(8,9,10,11,12,13,14)
 (1,2)(10,11)
]

and it would produce the list of permutations as elements of sym(14). Alternatively the first argument 14 could be omitted (then just take the maximum of all occurring moved points), or could be an existing permutation group.

(Of course instead of returning a list of permutations, it could also directly return a permutation group. I just figured being able to deal with a list of permutations is more general).

In principle it is clear to me how to implement this, but I figured it would be good to first get some feedback, perhaps people have better ideas for the syntax of this, which I'd like to hear before working on that macro :-)

@fingolfin fingolfin added enhancement New feature or request topic: groups labels Mar 21, 2022
@fingolfin fingolfin changed the title Feature: nicer syntax for entering permutations Nicer syntax for entering permutations Mar 21, 2022
@rfourquet
Copy link
Contributor

If not following the exact math notation is acceptable, you could also steal the {} syntax (e.g. [{1, 10}, {2, 11}, ...]), and allow direct input with a macro via SafeREPL ;-)

@fingolfin
Copy link
Member Author

@rfourquet I am not sure I follow, what is the proposal in terms for the way one enters the permutations (ignoring completely how this is implemented for the moment?) Would it just replace ( and ) by { and } and otherwise look identical? Or something else?

@thofma
Copy link
Collaborator

thofma commented Mar 21, 2022

Just for the record:

julia> using AbstractAlgebra

julia> perm"(1,2)(3,4)"
(1,2)(3,4)

@rfourquet
Copy link
Contributor

Would it just replace ( and ) by { and } and otherwise look identical?

Yes. But this syntax can be used only through a macro, so it would look like @perm [{1, 10}, {1, 2}{10, 11}] in regular code (or without the comma, e.g. {1 10}), but the @perm can be omitted in the REPL (but saving on typing @perm would be useful only if you input a lot of permutations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: groups
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants