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

move code from Oscar.jl/experimental/GModule/Misc.jl here #1675

Merged
merged 5 commits into from
Apr 25, 2024

Conversation

ThomasBreuer
Copy link
Collaborator

The idea is to add this code to AbstractAlgebra.jl, and then to remove it from Oscar.jl.

Once we agree what shall be really added here, tests and documentation have to be added.

(I am quite sure that I have put certain parts into the wrong files, and that some functions have to be changed.)

The idea is to add this code to AbstractAlgebra.jl,
and then to remove it from Oscar.jl.

Once we agree what shall be really added here,
tests and documentation has to be added.
(I am quite sure that I have put certain parts into the wrong files,
and that some functions have to be changed.)
@lgoettgens
Copy link
Collaborator

We need to adjust the signature here at least a little bit to not have something like oscar-system/Oscar.jl#3576 again.

@thofma
Copy link
Member

thofma commented Apr 17, 2024

Yes, I wonder how we plan to do this? This is breaking for Oscar 1.0 and master. We cannot move methods around in a backwards compatible way.

@lgoettgens
Copy link
Collaborator

Yes, I wonder how we plan to do this? This is breaking for Oscar 1.0 and master. We cannot move methods around in a backwards compatible way.

We can always put something like this into a "technically breaking" release of AA/Nemo/Hecke etc. as we plan to do with the printing changes anyway. Oscar 1.0 will never know about this, Oscar master just needs to get these functions removed in the same commit the AA compat is adapted.

@fingolfin
Copy link
Member

We are accumulating a bunch of "technically breaking" changes right now, so let's just label this as breaking, too, and make a new breaking release as soon as we have the (super)compact bits here cleaned up, too?

@fieker
Copy link
Contributor

fieker commented Apr 18, 2024 via email

I do not understand what is happening here:
Installing a `matrix(phi::IdentityMap{<:AbstractAlgebra.FPModule})` method
seems to make another `matrix` method unavailable?
@ThomasBreuer
Copy link
Collaborator Author

The tests failed.
When I remove a "harmless" matrix method then the failures disappear in my local installation.
(I do not understand what is happening here.)

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 8.47458% with 54 lines in your changes are missing coverage. Please review.

Project coverage is 86.39%. Comparing base (e2b898a) to head (7965826).
Report is 13 commits behind head on master.

Files Patch % Lines
src/Module.jl 0.00% 24 Missing ⚠️
src/generic/ModuleHomomorphism.jl 22.72% 17 Missing ⚠️
src/generic/DirectSum.jl 0.00% 4 Missing ⚠️
src/generic/Misc/Poly.jl 0.00% 3 Missing ⚠️
src/Map.jl 0.00% 2 Missing ⚠️
src/Matrix.jl 0.00% 2 Missing ⚠️
src/generic/FreeModule.jl 0.00% 1 Missing ⚠️
src/generic/Map.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1675      +/-   ##
==========================================
- Coverage   86.88%   86.39%   -0.49%     
==========================================
  Files         116      116              
  Lines       29652    29643       -9     
==========================================
- Hits        25764    25611     -153     
- Misses       3888     4032     +144     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fingolfin
Copy link
Member

Just to explain why this is "technically" breaking: because this will cause warnings in OSCAR of the kind "warning, method redefined in file X line Y, was previously defined in AbstractAlgebra; this may break precompilation". And then break CI tests, even though the methods we add here are identical to the ones in OSCAR. But Julia does not know this and panics.

@fingolfin
Copy link
Member

@ThomasBreuer what was the error you saw but did not understand? Perhaps if you can quote it here somebody has an idea?

src/Module.jl Outdated Show resolved Hide resolved
@@ -20,6 +20,10 @@ base_ring(N::DirectSumModule{T}) where T <: RingElement = base_ring(N.m[1])

base_ring(v::DirectSumModuleElem{T}) where T <: RingElement = base_ring(v.parent)

is_free(M::DirectSumModule) = all(is_free, M.m)
Copy link
Member

Choose a reason for hiding this comment

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

Actually, isn't this mathematically wrong? That is: if all summands are free, then M is free. But M might be free even though its summands are not (keyword: projective modules, etc.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fieker In which situation was is_free(::DirectSumModule) missing?

Copy link
Member

Choose a reason for hiding this comment

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

@thofma points out:

If it is only applied to finitely generated/presented modules over fields or PIDs, then the method is correct: $M \oplus N$ is free if and only if $M$ and $N$ are free.

This is of course true, but is there a way we can use this knowledge to improve the code above? I mean we could certainly restrict it to modules over fields; or over AA "integers", and AA univariates polynomials over fields, and perhaps a few more. But we can't do this generally here (e.g. not for fields over Nemo.ZZRing). But maybe we don't, it depends on what the application here is?

Copy link
Member

Choose a reason for hiding this comment

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

No, but it is the same for all the functionality of things involving FPModule.

Copy link
Member

Choose a reason for hiding this comment

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

Aha. The documentation indeed says:

# Free Modules and Vector Spaces

AbstractAlgebra allows the construction of free modules of any rank over any
Euclidean ring and the vector space of any dimension over a field. 

but that's the only place in docs/src/free_module.md mentioning Euclidean
and it then proceeds to say

AbstractAlgebra provides generic types for free modules and vector spaces,
via the type `FreeModule{T}` for free modules, where `T`
is the type of the elements of the ring $R$ over which the module is built.

which to makes it not at all clear whether or not e.g. FreeModule{T} is only supposed to be used over Euclidean rings.

And docs/src/direct_sum.md does not mention Euclidean/principal/PID at all.

But docs/src/module.md then goes on to say this

The generic code provided by AbstractAlgebra will only work for modules over
euclidean domains.

which ought to settle it, except it then proceeds in the very next sentence to say

Free modules can be built over both commutative and noncommutative rings. Other
types of module are restricted to fields and euclidean rings.

which again leaves it completely unclear to me what is supposed to work in which case or not.

I think adding an is_free method that knowingly returns wrong results sometimes is problematic. At the very least its docstring then should contain a big warning?

Better would be if we could just restrict it -- e.g. if this only for direct sums over integers or fields it'd be fine. But that begs the question where is even used -- @fieker?

Alternatively I could also live with such a method:

function is_free(M::DirectSumModule)
  f = all(is_free, M.m)
  @req f || is_euclidean(base_ring(M)) "is_free for direct sums over non-euclidean domains not supported"
  return f
end

is_euclidean(::Field) = true
is_euclidean(::ZZRing) = true
is_euclidean(::PolyRing{<:Field}) = true
is_euclidean(::Ring) = error("cannot tell if this ring is Euclidean")

@@ -220,6 +224,11 @@ function direct_sum(m::Vector{<:AbstractAlgebra.FPModule{T}}) where T <: RingEle
return M, inj, pro
end

function direct_sum(M::DirectSumModule{T}, N::DirectSumModule{T}, mp::Vector{ModuleHomomorphism{T}}) where T
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function should have hom in its name. In Oscar, we call the similar function that lifts homs to a tensor product hom_tensor. For direct sums, there is the equivalent for Lie algebra modules as hom_direct_sum, but we can adapt the name of that in Oscar to match this one here. But IMO it should start with hom_*

@ThomasBreuer
Copy link
Collaborator Author

what was the error you saw but did not understand? Perhaps if you can quote it here somebody has an idea?

When the matrix(phi::IdentityMap{<:AbstractAlgebra.FPModule}) method in src/generic/Map.jl gets installed, I get the following error.

julia> using AbstractAlgebra
[ Info: Precompiling AbstractAlgebra [c3fe647b-3220-5bb0-a1ea-a7954cac585d]

julia> M = free_module(ZZ, 2)
Free module of rank 2 over integers

julia> a = [ZZ(1), ZZ(2)]
2-element Vector{BigInt}:
 1
 2

julia> M(a)
ERROR: MethodError: no method matching matrix(::AbstractAlgebra.Integers{BigInt}, ::Int64, ::Int64, ::Vector{BigInt})
Stacktrace:
 [1] (::AbstractAlgebra.Generic.FreeModule{BigInt})(a::Vector{BigInt})
   @ AbstractAlgebra.Generic /export/home/sam/julia/packages/AbstractAlgebra.jl/src/generic/FreeModule.jl:132
 [2] top-level scope
   @ REPL[4]:1

julia> @which M(a)
(M::AbstractAlgebra.Generic.FreeModule{T})(a::Vector{S}) where {T<:NCRingElement, S<:RingElement} in AbstractAlgebra.Generic at /export/home/sam/julia/packages/AbstractAlgebra.jl/src/generic/FreeModule.jl:129

@fieker
Copy link
Contributor

fieker commented Apr 18, 2024 via email

@fieker
Copy link
Contributor

fieker commented Apr 18, 2024 via email

@lgoettgens
Copy link
Collaborator

Sorry, it was called hom

Just hom is fine for me as well. As long as it starts with hom I am happy

src/generic/Map.jl Outdated Show resolved Hide resolved
@ThomasBreuer
Copy link
Collaborator Author

Sorry, it was called hom

Just hom is fine for me as well. As long as it starts with hom I am happy

O.k., I will rename it to hom (also on the Oscar side).

@fieker
Copy link
Contributor

fieker commented Apr 19, 2024 via email

@thofma
Copy link
Member

thofma commented Apr 19, 2024

If it is only applied to finitely generated/presented modules over fields or PIDs, then the method is correct: $M \oplus N$ is free if and only if $M$ and $N$ are free.

@fingolfin
Copy link
Member

Maybe we can drop the is_free method from this PR for now / move it to a separate PR, so that we can proceed with merging the rest?


is_finite(M::FPModule{<:FinFieldElem}) = true

function is_sub_with_data(M::FPModule{T}, N::FPModule{T}) where T <: RingElement
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe rename to is_sub_with_inclusion?

src/Module.jl Outdated Show resolved Hide resolved
src/generic/DirectSum.jl Outdated Show resolved Hide resolved
@fingolfin
Copy link
Member

I've remove the gen(::FPModule, ::Int) method and the problematic is_free method. If tests pass we can merge this.

@fingolfin fingolfin merged commit 86dba7a into Nemocas:master Apr 25, 2024
29 of 31 checks passed
lgoettgens added a commit to lgoettgens/Oscar.jl that referenced this pull request May 1, 2024
lgoettgens added a commit to lgoettgens/Oscar.jl that referenced this pull request May 2, 2024
lgoettgens added a commit to lgoettgens/Oscar.jl that referenced this pull request May 2, 2024
lgoettgens added a commit to lgoettgens/Oscar.jl that referenced this pull request May 2, 2024
lgoettgens added a commit to lgoettgens/Oscar.jl that referenced this pull request May 3, 2024
thofma pushed a commit to oscar-system/Oscar.jl that referenced this pull request May 4, 2024
* Bump dependencies

* Remove moved aliases

* Add `base_ring_type` methods

* React to Nemocas/AbstractAlgebra.jl#1675

* React to Nemocas/Nemo.jl#1720

* Add QQBarField disambiguation method

* Require AA 0.41.2 with `Generic.hom` fix

* Add `base_ring(::QQAbField)`

* Fix doctests

* Fix booktests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants