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

import GAPGroups #84

Merged
merged 39 commits into from
May 8, 2020
Merged

import GAPGroups #84

merged 39 commits into from
May 8, 2020

Conversation

GDeFranceschi
Copy link
Contributor

The test for GAPGroups work on my laptop.

@fingolfin

This comment has been minimized.

@codecov
Copy link

codecov bot commented Apr 17, 2020

Codecov Report

Merging #84 into master will increase coverage by 15.63%.
The diff coverage is 66.46%.

@@             Coverage Diff             @@
##           master      #84       +/-   ##
===========================================
+ Coverage   12.37%   28.00%   +15.63%     
===========================================
  Files           7       12        +5     
  Lines        1641     2282      +641     
===========================================
+ Hits          203      639      +436     
- Misses       1438     1643      +205     
Impacted Files Coverage Δ
src/Modules/FreeModules-graded.jl 0.00% <0.00%> (ø)
src/Rings/mpoly.jl 30.34% <0.00%> (-0.41%) ⬇️
src/Groups/group_constructors.jl 43.01% <43.01%> (ø)
src/Groups/sub.jl 69.56% <69.56%> (ø)
src/Groups/GAPGroups.jl 79.12% <79.12%> (ø)
src/Groups/cosets.jl 84.61% <84.61%> (ø)
src/Groups/types.jl 96.15% <96.15%> (ø)
src/Oscar.jl 11.11% <100.00%> (+3.41%) ⬆️
... and 3 more

@fingolfin
Copy link
Member

@GDeFranceschi there is a weird test failure in one of the Travis tests, not visible in the others, in test/Groups/subgroups_and_cosets.jl:100 ; see https://travis-ci.com/github/oscar-system/Oscar.jl/jobs/320400236 -- any idea what might be going on?

@fingolfin
Copy link
Member

@GDeFranceschi that test uses random elements. So perhaps it only fails "sometimes". I didn't check the mathematics behind that test -- there are zero comments. I am sure I could figure it out given enough time, but perhaps you could just add some comments to explain it, and at the same time verify it is really correct, mathematically?

@rfourquet
Copy link
Contributor

i might be a structural member.

I omitted this aspect for simplicity, but this is part of why this solution is hacky, the structural members can be special cased (e.g. by using hasfield) in the getproperty method.

end

function show(io::IO, x::GroupCoset)
if x.side == :right
Copy link
Contributor

Choose a reason for hiding this comment

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

a = GAP.gap_to_julia(GAP.Globals.StringView(x.H.X))
b = GAP.gap_to_julia(GAP.Globals.StringView(x.repr.X))
if x.side == :right
    print(io, a, " * ", b)
else
    print(io, b, " * ", a)
end

is much more readable (at least to my eyes); You may also think about not using x.side directly, but to define side function for future maintainability

@fieker
Copy link
Contributor

fieker commented Apr 30, 2020 via email

@wbhart
Copy link
Contributor

wbhart commented May 1, 2020

@fieker I have no idea how you would achieve that. You can't ask a C library like Flint to use a Julia RNG. I think the best you can hope for is a way to seed the Flint RNG's (plural) from Julia, for reproducibility.

@rfourquet
Copy link
Contributor

You can't ask a C library like Flint to use a Julia RNG.

I'm not familiar with flint's RNG system, but there might be a way to use Julia's RNG if it's not too different from GMP's, with a POC at JuliaLang/julia#35111.

That said, seeding Fllint RNGs from Julia might indeed be good enough.

@wbhart
Copy link
Contributor

wbhart commented May 1, 2020

Well obviously you can't make Julia a dependency of Flint.

Anyhow, Flint has multiple RNG's as the GMP one is too heavy duty for some applications, and just as a matter of principle, libraries shouldn't be assumed to have RNG's compatible with the programs that call them. If I did that for Julia, I'd have to do it for everyone who asked.

I'm happy to add a facility to seed the Flint RNG's some day.

There are many different kinds of RNG's though, and Flint may add additional ones in the future, and seeds vary depending on the type of RNG. You'd be better off just asking for a function to seed all generators in a fixed way, with fixed seeds hard coded into Flint that the user doesn't have to supply. Of course then you are going to have the problem that the same tests are run all the time with no variation, which doesn't help find bugs.

So in that case you would be better asking for a function that returns an object which contains values which can be used to seed Flint in the same way in the future, without knowing what those seeds actually are.

@rfourquet
Copy link
Contributor

Well obviously you can't make Julia a dependency of Flint.

Sure, and similarly GMP doesn't depend on Julia. The mechanism is rather that GMP allows to provide your own C RNG, and Julia can provide a C interface to its RNG. But let's not hijack this already big PR, this is surely not urgent we can discuss it in more details somewhere else.

@fieker
Copy link
Contributor

fieker commented May 4, 2020 via email

@wbhart
Copy link
Contributor

wbhart commented May 4, 2020

Because malloc is a function and therefore has a standard interface. Randomness is a concept, for which there are many algorithms. There is no standard interface.

I already said what the correct way to handle this would be.

@fieker
Copy link
Contributor

fieker commented May 4, 2020 via email

@wbhart
Copy link
Contributor

wbhart commented May 4, 2020

Lots of things can go wrong with pseudorandom generators, e.g. they can for example decide to only return even numbers, or always with the top bits very similar or the bottom bits, or have very short periods, or be very non-uniform in their distribution, or have patterns in their output, odd even odd even. All of these things can and do go wrong if you take a naive approach.

We don't need cryptographically secure random generation (until we do), but we certainly need to care that generators are seeded appropriately, whether that be with 4096 bits of randomness or a pair of words or a random double in a specific range with certain properties or a pair of random primes with a certain number of bits. You can only generate an appropriate seed for a given generator if you know some specifics about the generator. The idea that you can replace a given generator with any supplied generator, or seed a given generator with any old seed is simply not correct.

We've hit this problem in Flint in the past, with things actually hanging because of poor quality random generation, which is precisely why we changed the way it's done.

Imagine someone tries to do an experiment to evaluate a conjecture computationally in Oscar and the distribution they get is subtly altered because of poor quality random generation!

@fieker
Copy link
Contributor

fieker commented May 4, 2020 via email

@wbhart
Copy link
Contributor

wbhart commented May 4, 2020

How am I not making myself clear here? There is no one way to do random generation! Even Flint doesn't have one random generator! And no, Flint's random generators absolutely suck eggs.

There is an ever so slightly better set of random generators here:

https://github.com/wbhart/bsdnt/tree/master/rand

I helped with it, but the substantial stuff is by Brian Gladman, based on work of George Marsaglia.

We discussed how to do it properly, but it would be a huge job. I vaguely recall this was a first attempt along that path. But we never brought it to completion:

https://github.com/wbhart/bsdnt/blob/master/sha1.c

SL(n::Int, q::Int)
return the special linear group of dimension `n` over the field GF(`q`). It is returned of type `T` for `T` = `MatrixGroup` or `PermGroup`.
"""
SL = special_linear_group
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
SL = special_linear_group
const SL = special_linear_group

Also, why is this here, and not where special_linear_group is defined? And why the duplicate documentation?

The same of course holds for GL, Sp, etc.

@fingolfin
Copy link
Member

@GDeFranceschi in order to be more systematic about your testing, you could take a look at the code coverage report for your branch here: https://codecov.io/gh/oscar-system/Oscar.jl/tree/GAPGroups/src/Groups

For example, looking at https://codecov.io/gh/oscar-system/Oscar.jl/src/GAPGroups/src/Groups/group_constructors.jl indicates that _gap_filter(::Type{FPGroup}) is never used, so perhaps some tests for FpGroups are in order. Also lots of other untested functions for which adding some tests would be a good idea.

if n < 1
throw(ArgumentError("n must be a positive integer"))
end
return T(GAP.Globals.SymmetricGroup(_gap_filter(T), n))
Copy link
Member

Choose a reason for hiding this comment

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

I think it would make more sense if symmetric_group(n::Int64) was implemented by calling symmetric_group(::Type{T}, n::Int) , i.e. symmetric_group(n::Int64) = symmetric_group(PermGroup, n)

@fingolfin fingolfin merged commit 75df26f into oscar-system:master May 8, 2020
@fingolfin
Copy link
Member

Thank you to everybody here for your comments. Please keep them coming!

That said, we merged this PR for now -- not because the work is done or complete or perfect or anything like that, but simply because this way at least we can use the bits we have now in some basic demos etc.

Note that there is no guarantee yet that anything will stay as it is -- this is still very much code in flux.

@GDeFranceschi please go through the unresolved comments here; where it makes sense, either address them to your new PR (once it has been created), or transfer the comments to new comments there.

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.

6 participants