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

Raising integers to finite-field elements coerces the base into the field #32287

Open
yyyyx4 opened this issue Jul 28, 2021 · 2 comments
Open

Comments

@yyyyx4
Copy link
Member

yyyyx4 commented Jul 28, 2021

In sage 9.3, raising an integer to a finite-field element in some cases coerces the base into the finite field. I think the correct behaviour should be to throw an error, or attempt to interpret the exponent as an integer (which is mathematically ill-defined but perhaps convenient).

Example:

sage: x = 123**GF(49)(5); x, x.parent()
(2, Finite Field in z2 of size 7^2)

Interestingly, this does not happen with prime finite fields, which inherit from integers modulo n:

sage: x = 123**GF(47)(5); x, x.parent()
(28153056843, Integer Ring)

Component: coercion

Keywords: finite fields, exponentiation

Issue created by migration from https://trac.sagemath.org/ticket/32287

@yyyyx4 yyyyx4 added this to the sage-9.4 milestone Jul 28, 2021
@yyyyx4 yyyyx4 modified the milestones: sage-9.4, sage-9.5 Aug 12, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 1, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
@Shay2Shay
Copy link
Contributor

Shay2Shay commented Aug 28, 2024

I was looking into the issue and found some of the past issue related to this
#24247 : It allowed coercion in power operation.
#15709 : It mentioned some inconvenience caused due to coercion.

I believe this issue can be fixed by making some changes here.

Shall we add support for FiniteField_givaro too? (and others FiniteField_ntl_gf2e or FiniteField_pari_ffelt)

Additional Info:

sage: x = 123**GF(64, impl='givaro')(5); x, x.parent()
(1, Finite Field in z6 of size 2^6)
sage: x = 123**GF(64, impl='pari_ffelt')(5); x, x.parent()
(1, Finite Field in z6 of size 2^6)
sage: 
sage: x = 123**GF(64, impl='ntl')(5); x, x.parent()
...
...
...
TypeError: unsupported operand parent(s) for ^: 'Finite Field in z6 of size 2^6' and 'Finite Field in z6 of size 2^6'

What should be right course of action here ?

  • Maybe we can remove feature
  • Maybe we can provide support for givaro and others
  • Maybe we can create a backend variable to handle such cases (similar to with proof which is used for primality testing)

@Shay2Shay
Copy link
Contributor

Shay2Shay commented Oct 2, 2024

I choose to dis-allow Finite Field with type p^n {n>1} to be used as argument for powering. (#38754)
Ex: 2 ** ( GF(2^6)(5) ) = Error

But this does not block earlier ModN implementation
Ex: 2 ** ( GF(29)(5) ) = No Error

I felt #38403 is also a similar issue

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

No branches or pull requests

3 participants