Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
345 stars 230 forks source link

maps between GaloisFields #2143

Open kschwede opened 3 years ago

kschwede commented 3 years ago

When trying to create a map between two moderately large GaloisFields, we get the following behavior.

i14 : map(GF(101^12), GF(101^2))

                                                       11    10      9      8      7      6      5      4     3     2
o14 = map (GF 1126825030131969720661201, GF 10201, {30a   + a   - 28a  + 39a  + 18a  - 26a  + 28a  + 48a  + 9a  - 9a  + 10a + 32})

o14 : RingMap GF 1126825030131969720661201 <--- GF 10201                                                                                                               

i15 : map(GF(101^14), GF(101^2))
stdio:15:1:(3): error: no method found for applying substitute to:
     argument 1 :  null (of class Nothing)
                    ZZ
     argument 2 :  ---[a] (of class PolynomialRing)                                                                                                                    
                   101

In particular, when the target field gets too big, it crashes. I tried messing around with the SizeLimit option, but that either doesn't help, or causes M2 itself to crash.

I haven't tried to figure out what is breaking yet.

8d1h commented 3 years ago

conwayPolynomial is not returning

i4 : conwayPolynomial(101, 14) === null

o4 = true
i14 : rawConwayPolynomial(101, 14, false)

o14 = {}

o14 : List

I guess it's because GF(101^14) is not in the database. In any case, there is this line

if not (isConway F and isConway K) then error "not implemented: maps between non-Conway Galois fields";

The error just arrived a bit earlier in the isConway function.

We can change this line https://github.com/Macaulay2/M2/blob/b5b9b18ccb0dbf4daeeefc69290f6f18331134ef/M2/Macaulay2/packages/ConwayPolynomials.m2#L31 to

isConway := (F) -> (cp := conwayPolynomial(F.char,F.degree, Variable=>F_0); cp =!= null and (gens ideal ambient F)_(0,0) == sub(cp, ambient ambient F))

to get the correct error.

kschwede commented 3 years ago

Thanks, that's really helpfu. At the very least in my code, I added a check of whether

conwayPolynomial(pp, d*myDeg))

is null. That way it wouldn't crash unexpectedly.
I agree that getting the correct / useful error there would be helpful. I'm happy to fix it in the M2 source, unless you have already done it.

8d1h commented 3 years ago

I agree that getting the correct / useful error there would be helpful. I'm happy to fix it in the M2 source, unless you have already done it.

Sure, go ahead :)