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

introduce on_points, on_tuples, ... #127

Merged
merged 2 commits into from
Oct 5, 2020
Merged

introduce on_points, on_tuples, ... #127

merged 2 commits into from
Oct 5, 2020

Conversation

ThomasBreuer
Copy link
Member

This is a first attempt to introduce action functions.
Once it is clear that this idea is o.k.,
more such functions have to follow, more methods have to be provided
(for example on_right for right cosets and group elements),
and then functions for orbits, stabilizers, induced permutations, etc.
can be added.

@thofma
Copy link
Collaborator

thofma commented Jul 10, 2020

Regarding the syntax, we could additionally overload directly x^g or g(x) respectively x * g and g * x. But this would just be syntactic sugar.

@fingolfin
Copy link
Member

Thank you! (if you haven't already, please also see PR #119, which I just merged (and which is super boring and nothing much happens, I thought it'd be good for you to be aware), and issue #108, which still lacks details ).

I envision that we will do two things in parallel:

  1. provide on_FOOBAR functions like this PR does
  2. provide a more Julia-like API which exploits the richer types for datastructures: when considering [[1,2], [3,4]]^g in GAP, this is ambiguous, hence we have OnSets, OnTuples, OnSetsSets, OnSetsTuples etc.. In Julia, though, we can use the type: Tuple vs. Set vs. BitSet etc. (and we probably will want some extra types, too: Set is great but for small sets with just a single digits of entries, it might be more efficient to use a "sorted vector" that works more like what GAP does; see e.g. https://github.com/tpapp/SortedVectors.jl or https://github.com/JuliaIntervals/IntervalOptimisation.jl/blob/master/src/SortedVectors.jl ; but actually we could just have our own super simple one which basically just adds a "tag" to the vector that it is meant to be sorted and should be transformed as such by permutations).

In the second approach, what Tommy wrote absolutely makes sense, as we can "automatically" decide for the "correct" action. In fact, I'd just implement the actions as such.

(However, I am not quite sure how to implement g(x) in terms of x^g, other than perhaps by inserting an inversion somewhere; that's about the only generic way to turn a right action into a left action, no?

Anyway, I'll look at this PR after our status meeting :-)

@codecov
Copy link

codecov bot commented Jul 10, 2020

Codecov Report

Merging #127 into master will decrease coverage by 0.30%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
- Coverage   33.12%   32.81%   -0.31%     
==========================================
  Files          20       21       +1     
  Lines        2992     3023      +31     
==========================================
+ Hits          991      992       +1     
- Misses       2001     2031      +30     
Impacted Files Coverage Δ
src/Groups/GAPGroups.jl 83.87% <ø> (-0.37%) ⬇️
src/Groups/action.jl 0.00% <0.00%> (ø)
src/Groups/types.jl 90.32% <ø> (ø)
src/Oscar.jl 6.81% <ø> (ø)

"""
on_tuples(tuple::GAP.GapObj, x::GAPGroupElem)
on_tuples(tuple::Vector{T}, x::GAPGroupElem) where T
on_tuples(tuple::T, x::GAPGroupElem) where T <: Tuple
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this instead:

Suggested change
on_tuples(tuple::T, x::GAPGroupElem) where T <: Tuple
on_tuples(tuple::Tuple{Vararg{T}}, x::GAPGroupElem) where T

Going beyond this (and perhaps beyond this PR): as mentioned already, for tuples, it'd also be natural to just define a ^ method directly, as it is "clear" how to act on that. Just as I'd argue that the default action for a vector ought to be OnRight, for a Set or BitSet OnSets etc. -- and then nested, i.e. a Set{Set{Int}} suggest OnSetsSets, while Set{Tuple{Vararg{Int8}}} suggests OnSetsTuples etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my variant, the tuple need not be homogeneous, and it is simpler to create the result object of the right type.

"""
on_points(pnt::GAP.GapObj, x::GAPGroupElem) = GAP.Globals.OnPoints(pnt, x.X)

on_points(pnt::GAPGroupElem, x::GAPGroupElem) = inv(x) * pnt * x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's inefficient, e.g. for permutations, conjugation can be computed much more efficiently than that. So I think it really should be this:

Suggested change
on_points(pnt::GAPGroupElem, x::GAPGroupElem) = inv(x) * pnt * x
on_points(pnt::GAPGroupElem, x::GAPGroupElem) = pnt ^ x

"""
on_points(pnt::GAP.GapObj, x::GAPGroupElem)
on_points(pnt::GAPGroupElem, x::GAPGroupElem)
on_points(pnt::Int, x::PermGroupElem)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honest question: What is the purpose in having on_points over just using :^? I.e. where one passes on_points as argument, couldn't one just pass ^ instead? It's quite likely I am missing something, but what? Note that I occasionally wonder the same about GAP.

"""
on_right(pnt::GAP.GapObj, x::GAPGroupElem)
on_right(pnt::GAPGroupElem, x::GAPGroupElem)
on_right(v::Vector{T}, x::MatrixGroupElem) where T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for OnPoints / on_points, what is the advantage of having on_right, as compared to just passing :* as "the action" whenever needed?

@fingolfin
Copy link
Member

@ThomasBreuer I just realized that I actually already left some feedback here, so waiting for your reply here now :-)

@fingolfin
Copy link
Member

@ThomasBreuer do you plan to update this PR?

@ThomasBreuer
Copy link
Member Author

@fingolfin Yes.

This is a first attempt to introduce action functions.
Once it is clear that this idea is o.k.,
more such functions have to follow, more methods have to be provided
(for example `on_right` for right cosets and group elements),
and then functions for orbits, stabilizers, induced permutations, etc.
can be added.
For example, `on_right`
- added a description what this is about
- define `^` as default action of permutations on (pos.) integers
- added natural action of permutations on multivariate polynomials
  by permuting indeterminates
- do not introduce `on_points`, `on_right`
on_indeterminates(f::GAP.GapObj, p::PermGroupElem)
on_indeterminates(f::Nemo.MPolyElem{T}, p::PermGroupElem) where T

Returns the image of `f` under `p`, w.r.t. permuting the indeterminates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns the image of `f` under `p`, w.r.t. permuting the indeterminates
Return the image of `f` under `p`, w.r.t. permuting the indeterminates

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for the hint.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me. I still would like us to also install default methods for ^ for acing on Tuple, Set, etc. "in the usual way", but that doesn't have to hold up this PR. Also, we'll still need dedicated actions anyway. E.g. when acting on a tuple or vector, while I'd consider on_tuples the "default", of course one could also act by permuting the tuple entries (on_positions? on_indices?)

Also, this should be consolidated with the to-be-fleshed-out concept of G-sets, but again, no need to hold this up for now.

Merge this at will?

@fieker
Copy link
Contributor

fieker commented Sep 4, 2020 via email

@ThomasBreuer
Copy link
Member Author

@fingolfin I do not understand your latest comment. The default methods for ^ had been added in the updated version of the pull request, and I had added also an explanation at the beginning of the file why one cannot use ^ in all situations --eventually this has to become part of the documentation, but currently all this is work in progress.

@fingolfin
Copy link
Member

@ThomasBreuer Sorry for the confusion. Apparently I was looking at an outdated version of the PR. I've force-reloaded and now see those ^ methods. I'll go over this PR once again.

@fingolfin fingolfin closed this Oct 2, 2020
@fingolfin fingolfin reopened this Oct 2, 2020
@fingolfin
Copy link
Member

Closing and re-opening to re-run the tests

@fingolfin fingolfin merged commit 476dd82 into oscar-system:master Oct 5, 2020
@ThomasBreuer ThomasBreuer deleted the TB_group_action_functions branch June 2, 2022 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants