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

Get fields to advertise their characteristic #36

Open
kwxm opened this issue Oct 11, 2019 · 1 comment
Open

Get fields to advertise their characteristic #36

kwxm opened this issue Oct 11, 2019 · 1 comment

Comments

@kwxm
Copy link
Collaborator

kwxm commented Oct 11, 2019

We should probably add a method to the Field typeclass to return the characteristic of a field. Among other things, this would let us add a test to make sure that the characteristic is actually prime (or zero). With Data.Field.Galois you can define a supposed field of characteristic 1000 by writing Prime 1000 for example, and you don't get any complaints (not surprisingly: you'd presumably need compile-time primality checking at the type level for that). Things will go wrong when you try to do calculations in this "field" though. If you're cutting and pasting numbers with dozens of digits then there's a danger that you might miss a digit or two, so we should add a test for this. Note that Data.Field.Galois already includes a char function which returns the characteristic.

We'd also need primality testing functions for large numbers, but implementations of these already exist: see for example
http://hackage.haskell.org/package/arithmoi-0.9.0.0/docs/Math-NumberTheory-Primes-Testing.html

See https://wiki.haskell.org/Prime_numbers for lots of information about primality testing.

@kwxm
Copy link
Collaborator Author

kwxm commented Oct 11, 2019

Note that the property tests for the field axioms aren't good enough to check this. If you take a large prime p and look at Z_(p^2) then it will automatically satisfy the ring axioms and the only possible problem is with invertibility of non-zero elements. However, in this ring everything is invertible except multiples of p, and if p is enormous then you're very unlikely to randomly select a multiple of p. Similar things are true in any ring Z_m where all of the prime factors of m are large.

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

2 participants