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

Rings of quadratic integers #73

Open
Bodigrim opened this issue Oct 1, 2017 · 12 comments
Open

Rings of quadratic integers #73

Bodigrim opened this issue Oct 1, 2017 · 12 comments

Comments

@Bodigrim
Copy link
Owner

Bodigrim commented Oct 1, 2017

It would be nice to implement a basic support for quadratic integers in arithmoi. There is a proof of concept in Math.NumberTheory.Quadratic.GaussianIntegers and Math.NumberTheory.Quadratic.EisensteinIntegers modules.

  1. Implement quadratic integers as a data type with two Integer fields and discriminant of the field D on the type level. One can copy the kind of discriminants from Numeric.QuadraticIrrational.SquareFree into arithmoi tree.
{-# LANGUAGE DataKinds      #-}
{-# LANGUAGE KindSignatures #-}

import GHC.TypeNats.Compat
import Numeric.QuadraticIrrational.SquareFree

data QuadraticInteger (d :: SquareFree)
  = QuadraticInteger { a :: Integer, b :: Integer }
  1. Define Num (QuadraticInteger d) instance. This will require definitions of conjugation and norm as well.

  2. For principal rings (D = −1, −2, −3, −7, −11, −19, −43, −67, −163) define a function primes, generating an infinite sequence of prime elements, ordered by norm. Use solveQuadratic to solve norm x = p and norm x = p^2 as described in this comment.

  3. Define UniqueFactorisation instance for principal rings.

  4. Define Euclidean instance for Euclidean rings.

@blperez01
Copy link

Currently have most of the functionality for this finished - just need to implement the unique factorization bit.

@Bodigrim
Copy link
Owner Author

A prototype can be found in #82.

@b-mehta
Copy link
Contributor

b-mehta commented Aug 17, 2018

Additionally, quadratic integers have periodic continued fractions so it would be nice to have this too - and then Pell equation solutions can be added. I have prototype code for continued fractions so I'm happy to help with that when appropriate.

@Bodigrim
Copy link
Owner Author

There are packages quadratic-irrational and pell already. However, the first one seems abandoned and I'd prefer to parametrise quadratic irrationals on type level, to avoid partial functions and allow Num instance.

@b-mehta
Copy link
Contributor

b-mehta commented Aug 21, 2018

Fair enough!

@Bodigrim
Copy link
Owner Author

Just for reference, I pushed some commits, reflecting my vision of quadratic rings, to https://github.com/ion1/quadratic-irrational/blob/c58c0fba08272c7e9fdff9fe8e338cff4d766ced/src/Numeric/QuadraticIrrational/Ring.hs

@rockbmb
Copy link
Contributor

rockbmb commented Sep 25, 2018

@Bodigrim I understand why you opened the issues you did over the past few months, things have been nicely progressing towards this issue. Point 2 seems the hardest, I agree. Plus for some values of D the quadratic integer ring won't be a Euclidean domain, or a Unique factorization domain. Tricky. I'll give it some more thought.

@Bodigrim
Copy link
Owner Author

Bodigrim commented Jan 5, 2019

Updated description to confirm with recent directions of development.

@Bodigrim
Copy link
Owner Author

@Multramate this is the issue I mentioned today.

@Multramate
Copy link

Thank you. It seems from reading the description above that this issue is meant to implement imaginary quadratic rings, as the real case would probably be harder to do e.g. there are probably infinitely many with unique factorisation. Would you reckon I should contribute by continuing from one of the prototypes, or think it over? I foresee unique factorisation to be done on a case-by-case basis, since there are only finitely many cases to consider:

instance UniqueFactorisation (ImQuadRing (-4)) where
  ...
instance UniqueFactorisation (ImQuadRing (-8)) where
  ...

Moreover, could you clarify the difficulty in doing (2)?

@Multramate
Copy link

Right - the discriminant as mentioned above refers to the d in Q(√d) and not the usual term used in number theory (at least in English), so it should be something like

instance UniqueFactorisation (ImQuadRing (-1)) where
  ...
instance UniqueFactorisation (ImQuadRing (-2)) where
  ...

Was worried for a bit since the quadratic ring is not unique given a fixed discriminant.

@Bodigrim
Copy link
Owner Author

It seems from reading the description above that this issue is meant to implement imaginary quadratic rings, as the real case would probably be harder to do e.g. there are probably infinitely many with unique factorisation.

I'd prefer to support both imaginary and real rings, under the same umbrella type, stratified by Nat on type-level. At least we can have a uniform Num instance for both, even if everything else will prove to be too difficult for real extensions.

Writing Num instance should be pretty straight-forward, I do not foresee any particular difficulties.

Would you reckon I should contribute by continuing from one of the prototypes, or think it over?

I would like to make it at least vaguely compatible with Math.NumberTheory.Quadratic.GaussianIntegers and Math.NumberTheory.Quadratic.EisensteinIntegers modules.

Not only feel free, but I encourage you to think over other aspects :)

Right - the discriminant as mentioned above refers to the d in Q(√d) and not the usual term used in number theory

You are right, sorry for confusion. I meant D as in wiki article.

Was worried for a bit since the quadratic ring is not unique given a fixed discriminant.

Yep, that is exactly the reason to stratify not by discriminant, but by its square-free part.

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

5 participants