Oscar.jl icon indicating copy to clipboard operation
Oscar.jl copied to clipboard

Promotion system for Galois fields not properly implemented?

Open HechtiDerLachs opened this issue 3 years ago • 6 comments

When I was trying to implement the ring interface for Oscar, I stumbled upon the following oddity:

promote_rule(fmpz, Int)

gives fmpz as expected. But

promote_rule(gfp_elem, Int)

returns Union{}. That's not correct, is it?

This seems to be breaking my tests...

HechtiDerLachs avatar Nov 04 '21 17:11 HechtiDerLachs

The gfp_elem type is defined in Nemo, so it should end up there. But if it is stalling your oscar tests, maybe put it in oscar with a TODO: move this to nemo

tthsqe12 avatar Nov 04 '21 17:11 tthsqe12

I'm trying to find the correct promote_rules to add, but I don't get through. So, it would be nice if someone could have a look at this with me or just provide the fix.

Tests just don't cover the Galois fields for now. But they should in the future.

HechtiDerLachs avatar Nov 05 '21 06:11 HechtiDerLachs

Alright, now it seems I could fix it. Turns out that promotion for gfp_mpoly was also not there, yet. The lines I need to add to make my tests run are

AbstractAlgebra.promote_rule(::Type{gfp_elem}, ::Type{fmpz}) = gfp_elem
AbstractAlgebra.promote_rule(::Type{gfp_mpoly}, ::Type{fmpz}) = gfp_mpoly

I could add them to my files with the TODO. But in any case: Could someone double check that these are the correct lines? For instance, I'm afraid, the promotion of Int64 is not covered by these, is it?

HechtiDerLachs avatar Nov 05 '21 07:11 HechtiDerLachs

This looks good. I will add them to AA today. The Int/Integer one would be

AbstractAlgebra.promote_rule(::Type{gfp_mpoly}, ::Type{<: Integer}) = gfp_mpoly

thofma avatar Nov 05 '21 08:11 thofma

But you can add them here too and we sort things out later. This should not hold up your PR.

thofma avatar Nov 05 '21 08:11 thofma

A variation of this still seems to be in play?

julia> Oscar.promote_rule(FqFieldElem, Int)
Union{}

julia> promote_rule(FqFieldElem, ZZRingElem)
Union{}

But I am not sure what exactly this breaks... ?

fingolfin avatar May 01 '24 22:05 fingolfin

Also

julia> promote_rule(fpFieldElem, Int)
Union{}

etc.

@thofma says "all of these should be added". So we just have to find/assign someone to do it.

fingolfin avatar May 29 '24 10:05 fingolfin

@thofma just naively volunteered (har har)

fingolfin avatar May 29 '24 10:05 fingolfin

Oscar.promote_rule is not what you want. It is working correctly with the correct function

julia> Nemo.promote_rule(FqFieldElem, Integer)
FqFieldElem

julia> Nemo.promote_rule(FqFieldElem, ZZRingElem)
FqFieldElem

thofma avatar May 29 '24 16:05 thofma