Support for Large Prime Field

23 views
Skip to first unread message

Wen-Ding Li

unread,
Dec 8, 2022, 8:43:22 PM12/8/22
to Macaulay2
Hi,

I'd like to work with some large prime field where the prime is ~ 256 bits integer. I tried
```

i36 : GF(2^256-189)

stdio:36:1:(3): error: expected argument 1 to be a small integer
```
and it seems that it is too big.

Does Macaulay2 support large prime fields? Could we use the Grobner basis solver with large prime fields?


Thanks!

Wen-Ding Li

Mahrud Sayrafi

unread,
Dec 9, 2022, 2:03:02 PM12/9/22
to maca...@googlegroups.com
I don't think M2 currently supports primes this large.

My understanding is that Flint supports Galois fields of cardinality at most 64 bits and Givaro much smaller. It's also possible to use multiprecision big integers for computations using either library and reduce after every step, but I don't think it's straightforward to adapt M2's Grobner basis computations this way.

Mahrud

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/macaulay2/8a72e146-3c88-4bab-8689-6d75e106b137n%40googlegroups.com.

Daniel R. Grayson

unread,
Dec 9, 2022, 2:36:17 PM12/9/22
to Macaulay2
You could try something like this:


i3 : ZZ[x,y,z]/(2^256-189)

                                        ZZ[x..z]
o3 = ------------------------------------------------------------------------------
     115792089237316195423570985008687907853269984665640564039457584007913129639747

o3 : QuotientRing


It won't be as efficient, but it might work for you.

Mahrud Sayrafi

unread,
Dec 10, 2022, 11:26:30 AM12/10/22
to maca...@googlegroups.com
Ah, I forgot about this trick!

Would it be worth adding an option or check to ZZp to do this automatically?

Mahrud

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.

Daniel R. Grayson

unread,
Dec 12, 2022, 12:24:50 PM12/12/22
to Macaulay2
Maybe it would be worth it.  If p is not small, then ZZ/p would return ZZ[ ]/p instead.  Mike might have an opinion.

Mahrud Sayrafi

unread,
Dec 12, 2022, 1:24:17 PM12/12/22
to maca...@googlegroups.com
It should probably return toField(ZZ[]/p) instead, so that the degree length is 0.

On Mon, Dec 12, 2022 at 11:24 AM Daniel R. Grayson <danielrich...@gmail.com> wrote:
Maybe it would be worth it.  If p is not small, then ZZ/p would return ZZ[ ]/p instead.  Mike might have an opinion.

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.

Daniel R. Grayson

unread,
Dec 12, 2022, 1:28:35 PM12/12/22
to Macaulay2
Good idea.


Daniel R. Grayson

unread,
Dec 12, 2022, 2:15:45 PM12/12/22
to Macaulay2
Maybe we should verify that p is actually prime before applying toField to ZZ[ ]/p.

We could also do ZZ[DegreeRank=>0]/p instead to get the degree length to be 0.


Reply all
Reply to author
Forward
0 new messages